Giter Club home page Giter Club logo

Comments (7)

faustomorales avatar faustomorales commented on July 20, 2024 7

Hi there! It appears you're running into an issue related to Shapely installation (pyinstaller/pyinstaller#2834). In the related issue, others suggested installing Shapely using conda-forge.

conda config --add channels conda-forge
conda install shapely

Does this resolve the issue?

from keras-ocr.

MounaBC avatar MounaBC commented on July 20, 2024 4

@leenremm I had the same issue on installing keras-ocr on a windows machine. The problem is with the Shapely package indeed. Installing it just with pip install wouldn't work. So I installed it using wheel.
The latest version of Shapely is 1.7.0 but it doesn't seem to work even if we use wheel. You can try installing another version (1.6.2.post2).
I don't really know why it doesn't work for the latest version but installing shapely by running :
pip install /path/to/whl/file.whl
and then running :
pip install keras-ocr
pip install tensorflow
worked for me.
You can find the whl file of the 1.6.2.post2 version of shapely for a windows machine and python version 3.7 attached here.
Hope it works for you!

Shapely-1.6.4.post2-cp37-cp37m-win_amd64.zip

from keras-ocr.

PawelSibczynski avatar PawelSibczynski commented on July 20, 2024 3

Hi everyone,

I had the same issue under Windows 10 and indeed it seems to be related with Shapely package.
In Anaconda, I solved the problem by downgrading Shapely to version 1.6.4 with: conda install shapely=1.6.4. I can confirm that the the solution mentioned by @MounaBC works.

I did it on three computers with Windows 10 and everytime it solved the problem.

from keras-ocr.

leenremm avatar leenremm commented on July 20, 2024

Here is what I found:

  1. Create a new virtual environment
mkdir venv
cd venv
mkdir project
python -m venv project
project\Scripts\activate.bat
  1. Install keras-ocr, and tensorflow
python -m pip install --upgrade pip
pip install keras-ocr
pip install tensorflow
  1. Install Shapely (as you suggest):
call conda config --add channels conda-forge
call conda install shapely

Anaconda output:

Collecting package metadata (current_repodata.json): done
Solving environment: /
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - defaults/win-64::anaconda==2019.10=py37_0
  - defaults/win-64::anaconda-navigator==1.9.7=py37_0
  - defaults/win-64::astropy==3.2.1=py37he774522_0
  - defaults/win-64::bkcharts==0.2=py37_0
  - defaults/win-64::bokeh==1.3.4=py37_0
  - defaults/win-64::bottleneck==1.2.1=py37h452e1ab_1
  - anaconda/win-64::conda==4.8.1=py37_0
  - defaults/win-64::conda-build==3.18.9=py37_3
  - defaults/win-64::conda-package-handling==1.6.0=py37h62dcd97_0
  - defaults/noarch::conda-verify==3.4.2=py_1
  - defaults/noarch::dask==2.5.2=py_0
  - defaults/win-64::h5py==2.9.0=py37h5e291fa_0
  - defaults/win-64::imageio==2.6.0=py37_0
  - anaconda/noarch::keras-applications==1.0.8=py_0
  - anaconda/win-64::keras-gpu==2.2.4=0
  - anaconda/noarch::keras-preprocessing==1.1.0=py_1
  - defaults/win-64::mkl_fft==1.0.14=py37h14836fe_0
  - defaults/win-64::mkl_random==1.1.0=py37h675688f_0
  - defaults/win-64::numba==0.45.1=py37hf9181ef_0
  - defaults/win-64::numexpr==2.7.0=py37hdce8814_0
  - defaults/win-64::numpy==1.16.5=py37h19fb1c0_0
  - anaconda/noarch::opt_einsum==3.1.0=py_0
  - defaults/win-64::pandas==0.25.1=py37ha925a31_0
  - defaults/win-64::patsy==0.5.1=py37_0
  - defaults/win-64::pytables==3.5.2=py37h1da0976_1
  - defaults/win-64::pytest-arraydiff==0.3=py37h39e3cac_0
  - defaults/win-64::pytest-astropy==0.5.0=py37_0
  - defaults/noarch::pytest-doctestplus==0.4.0=py_0
  - defaults/win-64::pywavelets==1.0.3=py37h8c2d366_1
  - defaults/win-64::seaborn==0.9.0=py37_0
  - defaults/win-64::statsmodels==0.10.1=py37h8c2d366_0
  - anaconda/win-64::tensorflow==2.0.0=gpu_py37h57d29ca_0
  - anaconda/win-64::tensorflow-gpu==2.0.0=h0d30ee6_0
failed with initial frozen solve. Retrying with flexible solve.
Solving environment: done
Collecting package metadata (repodata.json): done
Solving environment: -
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - defaults/win-64::anaconda==2019.10=py37_0
  - defaults/win-64::anaconda-navigator==1.9.7=py37_0
  - defaults/win-64::astropy==3.2.1=py37he774522_0
  - defaults/win-64::bkcharts==0.2=py37_0
  - defaults/win-64::bokeh==1.3.4=py37_0
  - defaults/win-64::bottleneck==1.2.1=py37h452e1ab_1
  - anaconda/win-64::conda==4.8.1=py37_0
  - defaults/win-64::conda-build==3.18.9=py37_3
  - defaults/win-64::conda-package-handling==1.6.0=py37h62dcd97_0
  - defaults/noarch::conda-verify==3.4.2=py_1
  - defaults/noarch::dask==2.5.2=py_0
  - defaults/win-64::h5py==2.9.0=py37h5e291fa_0
  - defaults/win-64::imageio==2.6.0=py37_0
  - anaconda/noarch::keras-applications==1.0.8=py_0
  - anaconda/win-64::keras-gpu==2.2.4=0
  - anaconda/noarch::keras-preprocessing==1.1.0=py_1
  - defaults/win-64::mkl_fft==1.0.14=py37h14836fe_0
  - defaults/win-64::mkl_random==1.1.0=py37h675688f_0
  - defaults/win-64::numba==0.45.1=py37hf9181ef_0
  - defaults/win-64::numexpr==2.7.0=py37hdce8814_0
  - defaults/win-64::numpy==1.16.5=py37h19fb1c0_0
  - anaconda/noarch::opt_einsum==3.1.0=py_0
  - defaults/win-64::pandas==0.25.1=py37ha925a31_0
  - defaults/win-64::patsy==0.5.1=py37_0
  - defaults/win-64::pytables==3.5.2=py37h1da0976_1
  - defaults/win-64::pytest-arraydiff==0.3=py37h39e3cac_0
  - defaults/win-64::pytest-astropy==0.5.0=py37_0
  - defaults/noarch::pytest-doctestplus==0.4.0=py_0
  - defaults/win-64::pywavelets==1.0.3=py37h8c2d366_1
  - defaults/win-64::seaborn==0.9.0=py37_0
  - defaults/win-64::statsmodels==0.10.1=py37h8c2d366_0
  - anaconda/win-64::tensorflow==2.0.0=gpu_py37h57d29ca_0
  - anaconda/win-64::tensorflow-gpu==2.0.0=h0d30ee6_0
done

Pip list:

absl-py==0.9.0
astor==0.8.1
cachetools==4.0.0
certifi==2019.11.28
chardet==3.0.4
cycler==0.10.0
decorator==4.4.1
editdistance==0.5.3
efficientnet==1.0.0
essential-generators==0.9.2
fonttools==4.4.0
gast==0.2.2
google-auth==1.11.2
google-auth-oauthlib==0.4.1
google-pasta==0.1.8
grpcio==1.27.2
h5py==2.10.0
idna==2.9
imageio==2.8.0
imgaug==0.4.0
Keras-Applications==1.0.8
keras-ocr==0.6.3
Keras-Preprocessing==1.1.0
kiwisolver==1.1.0
Markdown==3.2.1
matplotlib==3.1.3
networkx==2.4
numpy==1.18.1
oauthlib==3.1.0
opencv-python==4.2.0.32
opt-einsum==3.1.0
Pillow==7.0.0
protobuf==3.11.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyclipper==1.1.0.post3
pyparsing==2.4.6
python-dateutil==2.8.1
PyWavelets==1.1.1
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
scikit-image==0.16.2
scipy==1.4.1
Shapely==1.7.0
six==1.14.0
tensorboard==2.1.0
tensorflow==2.1.0
tensorflow-estimator==2.1.0
termcolor==1.1.0
tqdm==4.43.0
urllib3==1.25.8
validators==0.14.2
Werkzeug==1.0.0
wrapt==1.12.0

Same error when running the sample code:

(project) (base) C:\Users\...\Documents>python main.py

2020-02-23 15:03:06.027923: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-02-23 15:03:06.031828: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    import keras_ocr
  File "C:\Users\...\Documents\venv\project\lib\site-packages\keras_ocr\__init__.py", line 1, in <module>
    from . import (detection, recognition, tools, data_generation, pipeline, evaluation, datasets,
  File "C:\Users\...\Documents\venv\project\lib\site-packages\keras_ocr\detection.py", line 31, in <module>
    from . import tools
  File "C:\Users\...\Documents\venv\project\lib\site-packages\keras_ocr\tools.py", line 14, in <module>
    from shapely import geometry
  File "C:\Users\...\Documents\venv\project\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
    from .base import CAP_STYLE, JOIN_STYLE
  File "C:\Users\...\Documents\venv\project\lib\site-packages\shapely\geometry\base.py", line 18, in <module>
    from shapely.coords import CoordinateSequence
  File "C:\Users\...\Documents\venv\project\lib\site-packages\shapely\coords.py", line 8, in <module>
    from shapely.geos import lgeos
  File "C:\Users\...\Documents\venv\project\lib\site-packages\shapely\geos.py", line 145, in <module>
    _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
  File "C:\Users\...\Anaconda3\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Do you have a sample venv_setup script for Windows 10?

from keras-ocr.

faustomorales avatar faustomorales commented on July 20, 2024

I don't have access to a Windows machine, unfortunately but @Johndirr appears to have successfully gotten the package running on Windows.

It does seem pretty clear that this is a problem with getting Shapely installed. For debugging, I would suggest starting with a clean environment and trying to just get from shapely import geometry to work. Once it does, then you should be able to install keras-ocr and the remaining dependencies successfully.

I apologize for not having more helpful advice. Short of getting a Windows machine or refactoring out Shapely as a dependency (which perhaps we should do -- though it won't be easy), I'm not sure how else to resolve.

If you do figure it out, please do post back here and we can add what you found to the documentation for other Windows users.

from keras-ocr.

leenremm avatar leenremm commented on July 20, 2024

Thanks @MounaBC, that worked!

For those having the same issue, see below a script to setup a venv on Windows 10:

:: =================================================
:: Create new Virtual Environment
:: =================================================

mkdir venv
cd venv
mkdir project
call python -m venv project
call project\Scripts\activate.bat

pip freeze

:: =================================================
:: Install Python Packages and Dependencies
:: =================================================

python -m pip install --upgrade pip
pip install D:\Software\Shapely-1.6.4.post2-cp37-cp37m-win_amd64\Shapely-1.6.4.post2-cp37-cp37m-win_amd64.whl
pip install keras-ocr
pip install tensorflow

cd ../

pip freeze

from keras-ocr.

atharva21jadhav avatar atharva21jadhav commented on July 20, 2024

Thanks @MounaBC the solution worked on my machine. The step by step guide from @leenremm is something one should follow in future.

from keras-ocr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.