Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting typeerror object of type 'NoneType' has no len() #267

Closed
CruzzRazor opened this issue Nov 30, 2017 · 12 comments · Fixed by #268
Closed

getting typeerror object of type 'NoneType' has no len() #267

CruzzRazor opened this issue Nov 30, 2017 · 12 comments · Fixed by #268

Comments

@CruzzRazor
Copy link

CruzzRazor commented Nov 30, 2017

i am trying to ./runtest i am getting error saying

$ ./run-test
INFO:  # ./tests/testpage.png
INFO:  === ./tests/testpage.png 1
INFO:  estimating skew angle
INFO:  estimating thresholds
INFO:  rescaling
INFO:  ./tests/testpage.png lo-hi (0.39 1.44) angle  0.1 no-normalization
INFO:  writing
INFO:
INFO:  ########## C:/Users/allud/ocropy/env/Scripts/ocropus-gpageseg temp/????
INFO:
INFO:  temp\0001.bin.png
INFO:  scale 19.493589
INFO:  computing segmentation
INFO:  computing column separators
INFO:  considering at most 3 whitespace column separators
INFO:  computing lines
INFO:  propagating labels
INFO:  spreading labels
INFO:  number of lines 100
INFO:  finding reading order
INFO:  writing lines
INFO:      91  temp\0001.bin.png 19.5 92
INFO:
INFO:  ########## C:/Users/allud/ocropy/env/Scripts/ocropus-rpred -n temp/????
INFO:
INFO:  #inputs: 92
Traceback (most recent call last):
  File "C:/Users/allud/ocropy/env/Scripts/ocropus-rpred", line 120, in <module>
    network = ocrolib.load_object(args.model,verbose=1)
  File "c:\python27\Lib\ocrolib\common.py", line 435, in load_object
    fname = ocropus_find_file(fname)
  File "c:\python27\Lib\ocrolib\common.py", line 625, in ocropus_find_file
    sysconfig.get_config_var("datarootdir"), "ocropus"))
  File "C:\Users\allud\ocropy\env\lib\ntpath.py", line 65, in join
    result_drive, result_path = splitdrive(path)
  File "C:\Users\allud\ocropy\env\lib\ntpath.py", line 115, in splitdrive
    if len(p) > 1:
TypeError: object of type 'NoneType' has no len()
(env)

please help.

@kba
Copy link
Collaborator

kba commented Nov 30, 2017

Do you have en-default.pyrnn.gz in ./models?

@CruzzRazor
Copy link
Author

yes i have it. i have downloaded the en-default.pyrnn.gz file from link & pasted it as it is as am using it on windows. do i need to extract it ?

@kba
Copy link
Collaborator

kba commented Nov 30, 2017

No, it's a Windows issue, I think

sysconfig.get_config_var("datarootdir")

returns

None

in Windows. Can you confirm that, i.e. try

python -c "import sysconfig;print(sysconfig.get_config_var('datarootdir'))"

@CruzzRazor
Copy link
Author

CruzzRazor commented Nov 30, 2017

yes it returns none. what does that mean?

@CruzzRazor
Copy link
Author

so what do i need to do? is it a bug? how can i fix this?

@kba
Copy link
Collaborator

kba commented Nov 30, 2017

It's a bug, please merge #268 locally and see if the issue goes away:

git fetch origin
git merge origin/windows-sysconfig

I'll try it the next time I have access to a Windows machine.

(If you want to just get up and running, comment out https://github.com/tmbdev/ocropy/blob/master/ocrolib/common.py#L624-L625 until #268 is resolved)

@stweil
Copy link
Contributor

stweil commented Nov 30, 2017

There exist different Python binaries for Windows. It looks like the official Python releases for Windows neither use cmake nor autotools for building, so those binaries do not know datarootdir. The Python binaries from Cygwin return a valid path.

@CruzzRazor
Copy link
Author

@kba nope its not working though. i am looking for an OCR engine other than tesseract with good accuracy as its bit urgent. can you please suggest any alternative to ocropy if possible to get the things done for a while.

@stweil
Copy link
Contributor

stweil commented Nov 30, 2017

@CruzzRazor, which error do you get now (with the code fix suggested by @kba)? And why does Tesseract not fit your needs?

@CruzzRazor
Copy link
Author

CruzzRazor commented Nov 30, 2017

@stweil this is what i am getting now

$ ./run-test
INFO:  # ./tests/testpage.png
INFO:  === ./tests/testpage.png 1
INFO:  estimating skew angle
INFO:  estimating thresholds
INFO:  rescaling
INFO:  ./tests/testpage.png lo-hi (0.39 1.44) angle  0.1 no-normalization
INFO:  writing
INFO:
INFO:  ########## C:/Users/allud/ocropy/env/Scripts/ocropus-gpageseg temp/????
INFO:
INFO:  temp\0001.bin.png
INFO:  scale 19.493589
INFO:  computing segmentation
INFO:  computing column separators
INFO:  considering at most 3 whitespace column separators
INFO:  computing lines
INFO:  propagating labels
INFO:  spreading labels
INFO:  number of lines 100
INFO:  finding reading order
INFO:  writing lines
INFO:      91  temp\0001.bin.png 19.5 92
INFO:
INFO:  ########## C:/Users/allud/ocropy/env/Scripts/ocropus-rpred -n temp/????
INFO:
INFO:  #inputs: 92
# loading object .\models\en-default.pyrnn.gz
Traceback (most recent call last):
  File "C:/Users/allud/ocropy/env/Scripts/ocropus-rpred", line 120, in <module>
    network = ocrolib.load_object(args.model,verbose=1)
  File "c:\python27\Lib\ocrolib\common.py", line 445, in load_object
    return unpickler.load()
EOFError
(env)

@urhub
Copy link

urhub commented Nov 30, 2017

@CruzzRazor, If you are using Windows 10, you could try running Ocropy on bash for windows 10.
https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10
The files you download on windows can be accessed in bash at /mnt/c/path_to_download_directory

i am looking for an OCR engine other than tesseract with good accuracy as its bit urgent.

@zuphilip
Copy link
Collaborator

zuphilip commented Dec 8, 2017

@CruzzRazor This looks like a new issue. Can you open another issue if this persist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants