Keras_ocr fails to import - python

I am trying to use Keras_ocr for a project, but I can't get it to import to my script. I am using tensorflow backend (non-gpu).
Here is the error code I am receiving:
Traceback (most recent call last):
File "C:/Users/Cameron/PycharmProjects/NN-1/Test 1.py", line 5, in <module>
import keras_ocr
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\keras_ocr\__init__.py", line 1, in <module>
from . import (detection, recognition, tools, data_generation, pipeline, evaluation, datasets,
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\keras_ocr\detection.py", line 31, in <module>
from . import tools
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\keras_ocr\tools.py", line 14, in <module>
from shapely import geometry
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\geometry\base.py", line 18, in <module>
from shapely.coords import CoordinateSequence
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\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\Cameron\Anaconda3\envs\TensorEnv\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I installed keras_ocr via pip.

This is a known issue where Keras_ocr finds the wrong DLL or can't find it at all. It can be solved simply by updating Keras_ocr or uninstalling and reinstalling keras_ocr.

Try installing Python=3.6 and the latest Tensorflow version, after that install keras_ocr.
That should work.

Related

WinError 87 - The parameter is incorrect: '.\\Library\\bin

I am tring to call VectorBT using C#, a python package for backtesting.
Meeting the below bug:
'[WinError 87] The parameter is incorrect: '.\Library\bin''
File "D:\ProgramData\Anaconda3\lib\os.py", line 1111, in add_dll_directory
cookie = nt._add_dll_directory(path)
File "D:\ProgramData\Anaconda3\lib\site-packages\llvmlite\binding\ffi.py", line 162, in <module>
os.add_dll_directory(os.path.join(os.path.normpath(sys.prefix), 'Library', 'bin'))
File "D:\ProgramData\Anaconda3\lib\site-packages\llvmlite\binding\dylib.py", line 3, in <module>
from llvmlite.binding import ffi
File "D:\ProgramData\Anaconda3\lib\site-packages\llvmlite\binding\__init__.py", line 4, in <module>
from .dylib import *
File "D:\ProgramData\Anaconda3\lib\site-packages\numba\core\config.py", line 15, in <module>
import llvmlite.binding as ll
File "D:\ProgramData\Anaconda3\lib\site-packages\numba\__init__.py", line 19, in <module>
from numba.core import config
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\_typing.py", line 15, in <module>
from numba.core.registry import CPUDispatcher
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\generic\drawdowns.py", line 171, in <module>
from vectorbt import _typing as tp
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\generic\__init__.py", line 8, in <module>
from vectorbt.generic.drawdowns import Drawdowns
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\__init__.py", line 12, in <module>
from vectorbt.generic import nb, plotting
at Python.Runtime.PythonException.ThrowLastAsClrException()
at Python.Runtime.PyModule.Import(String name)
at PythonnetSampleConsoleApp.VectorBT.VectorBTMethod() in E:\Github\PythonNetSample\src\PythonnetSampleConsole\VectorBT.cs:line 64
at PythonnetSampleConsoleApp.Program.Main(String[] args) in E:\Github\PythonNetSample\src\PythonnetSampleConsole\Program.cs:line 32
Printscreen: https://i.stack.imgur.com/9dN1a.png
Any suggestion?
Does Anaconda3 contain the VectorBt package?
Environment: Visual Studio 2022 + Anaconda3
I found the reason, it's because that anaconda3 does not contain the package "vectorBT". But when I install using
"conda install vectorbt", I got the below notice “package not found error, the following packages are not available from current channels”
print screen: [1]: https://i.stack.imgur.com/H1Frh.png
follow up question: how to install vectorbt to anaconda3?

sklearn import fail because of scipy. OSError: [WinError 126] The specified module could not be found

Introduction
I need to use the 'KMeans' function from 'sklearn.cluster'. I am on PyCharm using Python 3.7 with a virtualvenv environment. I can add the necessary packages in order to use 'sklearn' using pip (I meen 'numpy', 'scipy', 'scikit-learn'...). Unfortunately there is an error when I run a python file in which I import 'sklearn'. I don't know why there is an error and how can I fixed it...
My problem is that the import is not working. When I run from sklearn.cluster import KMeans, it returns "OSError: [WinError 126]" :
Traceback (most recent call last):
File "C:/Users/username/PycharmProjects/Test2/main.py", line 3, in <module>
import sklearn
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\__init__.py", line 80, in <module>
from .base import clone
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\base.py", line 21, in <module>
from .utils import _IS_32BIT
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\scipy\__init__.py", line 136, in <module>
from . import _distributor_init
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I think that there is a problem with the packages versions. If you want to see the packages versions (pip freeze result) :
numpy==1.19.3
scikit-learn==0.23.2
scipy==1.5.4
sklearn==0.0
threadpoolctl==2.1.0
Edit
I have found that there is a problem with scipy version. When I run 'import scipy' there is the same type of error (OSError: [WinError 126] The specified module could not be found). A solution is to downgrade scipy 1.5.4 to scipy 1.4.1 (ref Error when loading scipy: OSError: [WinError 126] The specified module could not be found). The [WinError 126] error disappears.
Unfortunately there is another problem coming. Now when I run from sklearn.cluster import KMeans, there is this error :
Traceback (most recent call last):
File "C:/Users/username/PycharmProjects/Test2/main.py", line 1, in <module>
from sklearn.cluster import KMeans
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\__init__.py", line 80, in <module>
from .base import clone
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\base.py", line 21, in <module>
from .utils import _IS_32BIT
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\utils\__init__.py", line 23, in <module>
from .class_weight import compute_class_weight, compute_sample_weight
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\utils\class_weight.py", line 7, in <module>
from .validation import _deprecate_positional_args
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\utils\validation.py", line 25, in <module>
from .fixes import _object_dtype_isnan, parse_version
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\sklearn\utils\fixes.py", line 18, in <module>
import scipy.stats
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\scipy\stats\stats.py", line 179, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\username\PycharmProjects\Test2\venv\lib\site-packages\scipy\spatial\__init__.py", line 99, in <module>
from .qhull import *
ImportError: DLL load failed: The specified module could not be found.
It seems to be a more common error so I am checking.
I encountered a similar problem and my solution was setting up a new virtual environment and using a python 3.9 interpreter instead of 3.7.
This way ImportError: DLL load failed: The specified module could not be found. was solved, too.
I hope you already solved this issue but maybe someone else will face this problem in the future
I find a solution : use conda python interpretor. There is maybe a problem with the virtualvenv environment of PyCharm.
Check this well known post if you want more details : In pycharm ImportError: DLL load failed: The specified module could not be found. while importing facerecognition

How to fix:- libmxnet.so: cannot open shared object file: No such file or directory

I'm trying to install mxnet on Yocto (Rocko) for my 64-bit Armv8-A.
I did pip3 install mxnet and it was successfully installed. It was installed in -
/usr/lib/python3.5/site-packages
I copied mxnet and mxnet-1.6.0.dist-info to -
/usr/lib64/python3.5/site-packages
Then, i tried import mxnet and it gave me the below errors-
ERROR:
>>> import mxnet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.5/site-packages/mxnet/__init__.py", line 24, in <module>
from .context import Context, current_context, cpu, gpu, cpu_pinned
File "/usr/lib64/python3.5/site-packages/mxnet/context.py", line 24, in <module>
from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
File "/usr/lib64/python3.5/site-packages/mxnet/base.py", line 214, in <module>
_LIB = _load_lib()
File "/usr/lib64/python3.5/site-packages/mxnet/base.py", line 205, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File "/usr/lib64/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib64/python3.5/site-packages/mxnet/libmxnet.so: cannot open shared object file: No such file or directory
I checked and there is libmxnet.so in my /usr/lib64/python3.5/site-packages/mxnet/ folder.
How do i solve this issue?
mxnet on ARM must be built from source, as per this GitHub issue.
Instructions on how to do this can be found here.

sklearn: Getting error while importing sklean in jupyter notebook

Importing sklearn gives error in anaconda jupyter notebook. I have installed scikitlearn package and issue is still seen.
Traceback (most recent call last):
File "version.py", line 18, in <module>
import sklearn
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\__init__.py", line 13
4, in <module>
from .base import clone
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\base.py", line 13, in
<module>
from .utils.fixes import signature
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", l
ine 11, in <module>
from .validation import (as_float_array,
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py",
line 18, in <module>
from ..utils.fixes import signature
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\fixes.py", line
144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.
py", line 118, in <module>
from .matfuncs import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\matfuncs.
py", line 19, in <module>
import scipy.special
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\special\__init__.py", l
ine 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified procedure could not be found.
(base) C:\Windows\system32>
As referred in this link that looks similar. You probably dont have c++ windows compiler. You will need to install Visual C++ Redistributable and then reinstalling anaconda might solve the issue.
On a side note anaconda generally takes care of the installing of the c++ compiler. Did you create virtualenv and pip install. I will suggest you install using conda install.
conda install scipy

Installing numba onto Linux 7.0 - error with prerequisite llvmlite library diectory

I'm new to Linux and generally installing packages via command line syntax.
I've tried installing numba (to use jit) into Python and this is the error I receive.I did this originally with GitHub source, and again with Anaconda. Numba appear to be installed correctly in the command line, however when I try to import into Spyder I get the below error
llvmlite imports without error.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/__init__.py", line 7, in <module>
from . import testing, decorators
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/testing.py", line 6, in <module>
from numba import config
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/config.py", line 9, in <module>
import llvmlite.binding as ll
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/__init__.py", line 6, in <module>
from .dylib import *
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/dylib.py", line 4, in <module>
from . import ffi
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/ffi.py", line 43, in <module>
lib = ctypes.CDLL(_lib_name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory

Categories