qurator-spk / sbb_binarization

Document Image Binarization
Apache License 2.0
69 stars 14 forks source link

Cannot install sbb_binarization (on Windows) - TensorFlow not found (even, if available) #19

Closed stefanCCS closed 1 year ago

stefanCCS commented 3 years ago

Hi, I am trying out to setup your nice tool in Windows environment. I am using Python 3.8. After doing "pip install sbb_binarization" I get the following error:

Collecting ocrd>=2.18.0
  Using cached ocrd-2.20.1-py3-none-any.whl (51 kB)
ERROR: Could not find a version that satisfies the requirement tensorflow<1.16,>=1.15 (from sbb_binarization) (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.4.0rc0, 2.4.0rc1)
ERROR: No matching distribution found for tensorflow<1.16,>=1.15 (from sbb_binarization)

If i call "pip list", I can see, that TensorFlow is installed:

...
setuptools             41.2.0
six                    1.14.0
stomp.py               6.0.0
tensorboard            2.4.0
tensorboard-plugin-wit 1.7.0
tensorflow             2.3.1
tensorflow-estimator   2.3.0
termcolor              1.1.0
urllib3                1.26.2
...
Do you have any idea, what to do?
kba commented 3 years ago

sbb_binarization requires tensorflow < 1.16. There are no pre-built packages on PyPI for Python 3.8 for tensorflow < 2.2.

I suspect you had tensorflow (2.3.1) installed before.\

I recommend downgrading to python 3.7 for which there are pip-installable tensorflow 1.15.x packages available.

stefanCCS commented 3 years ago

Thanks! Python 3.7 works much better. pip install sbb_binarize has finished successfully, see this pip list extract:

PyYAML                 5.3.1
requests               2.25.0
sbb-binarization       0.0.5
scipy                  1.5.4
setuptools             50.3.2
Shapely                1.7.1
six                    1.15.0
tensorboard            1.15.0
tensorflow             1.15.4
tensorflow-estimator   1.15.1
termcolor              1.1.0

Trying to run sbb_binarize.py leads to a missing module "cv2".

sbb_binarize.py", line 13, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

What do I need here?

cneud commented 3 years ago

cv2 should be installable by pip install opencv-python.

stefanCCS commented 3 years ago

Ok, opencv now installed (see pip list here):

ocrd-validators        2.20.1
opencv-python          4.4.0.46
opencv-python-headless 4.4.0.46
opt-einsum             3.3.0
pdfcrowd               4.4.2

But, still same error (Module cv2 not found). Next idea, please ;-)

kba commented 3 years ago

You mustn't install opencv-python{,-headless} side-by-side. But more importantly, you should not have to install opencv-python manually at all, they should come with ocrd{,_*}.

Can you uninstall both opencv-python and -headless and retry the installation?

pip uninstall opencv-python-{,headless}
pip install sbb_binarization
stefanCCS commented 3 years ago

Thanks again, for helping ...

Maybe I have not made in clear enough before: I could successfully install sbb_binarize in my Linux environment with just updating ocrd_all! Now, I try just to install sbb_binarize in Windows environment (not full ocrd_all). I hope it is more clear now, what I try to do ...

Concerning your proposal: I did the unistallation of opencv-python plus ... -headless --> has run ok. I did pip install sbb_binarization again --> has run ok. Results in this pip list (extract):

numpy                  1.18.5
ocrd                   2.20.1
ocrd-modelfactory      2.20.1
ocrd-models            2.20.1
ocrd-utils             2.20.1
ocrd-validators        2.20.1
opencv-python-headless 4.4.0.46
opt-einsum             3.3.0
pdfcrowd               4.4.2
pika                   1.0.0b2
Pillow                 8.0.1
pip                    20.0.2
protobuf               3.14.0
pyrsistent             0.17.3
PyYAML                 5.3.1
requests               2.25.0
sbb-binarization       0.0.5
scipy                  1.5.4

BUT, the error not finding cv2 is still there :-( If you still have some ideas, what to do, of course I would appreciate it. If not, it is neither urgent nor very important - we simply could ignore this problem (and I will stay in Linux only).

cneud commented 3 years ago

SO suggests that some have been able to resolve this by using the unofficial Windows wheels distributed by Gohlke.

stefanCCS commented 3 years ago

Ok, one step further. Using opencv_python-4.4.0-cp37-cp37m-win_amd64.whl (I have Python 3.7, 64bit) from Gohlke site, I now get the following error (shortend):

Processing c:\users\heide.ccs-hh-ewi\documents\python\opencv_python-4.4.0-cp37-cp37m-win_amd64.whl
ERROR: Exception:
Traceback (most recent call last):
  File "c:\users\heide.ccs-hh-ewi\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\cli\base_command.py", line 186, in _main
    status = self.run(options, args)
  File "c:\users\heide.ccs-hh-ewi\appdata\local\programs\python\python37\lib\site-packages\pip\_internal\commands\install.py", ...
...
    zip = zipfile.ZipFile(zipfp, allowZip64=True)
  File "c:\users\heide.ccs-hh-ewi\appdata\local\programs\python\python37\lib\zipfile.py", line 1222, in __init__
    self._RealGetContents()
  File "c:\users\heide.ccs-hh-ewi\appdata\local\programs\python\python37\lib\zipfile.py", line 1289, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

Again, if you still have ideas - very nice; if not, also ok.

stefanCCS commented 3 years ago

Update: I did pip uninstall opencv-python. Then, I made a pip install with the Gohlke-Wheel - has run fine BUT, still when starting sbb_binarize: "module cv2 not found" :-(

apacha commented 1 year ago

I've tested this project with Python 3.6 and Python 3.9, Tensorflow 2.5.0 - 2.9.1, which are available on Windows and managed to get it up and running (except the model deserialization was a bit tricky), so I think this issue can be closed.

stefanCCS commented 1 year ago

As I am the original creator of this issue, I will close it now. Please feel free to re-open it, in case you want to keep it open for some purpose.