I installed tesseract-OCR for windows and it resides in C:\Program Files\Tesseract-OCR path in my system.
I set up an environment variable by adding C:\Program Files\Tesseract-OCR in the PATH variable.
I also set up TESSDATA_PREFIX in system variable to the same above tesseract location.
Still, when I try to run the command "tesseract some path\image.tif somepath\output", it gives message as "'tesseract' is not recognized as an internal or external command".
when i run the same command from the location where tesseract is installed, it works fine but i need to have it set in the environment variables as it will also allow PYOCR wrapper to recognise it.
PYOCR is currently giving "pyocr.get_available_tools()[0]" as empty list.
any help is much appreciated.
Perhaps my answer is a little bit late, but I will give my setup that seems to work from few minutes. As you, I was using PYOCR library, and at the beginning I get an empty list when using pyocr.get_available_tools().
I'm running it on a Windows 10 laptop.
First, I installed Tesseract in version 4 in alpha from here:
https://github.com/UB-Mannheim/tesseract/wiki and then added location in my windows user PATH variable. From here, run a new command line and check that tesseract tool is detected, if not you're environmment is not properly configured!
Then, I installed PyOCR using a simple pip pyocr and use the follow imports
before using pyocr functions:
import pyocr
import pyocr.builders
EDIT:
I've look in current source files of PYOCR and I've found this:
def is_available():
_set_environment()
return util.is_on_path(TESSERACT_CMD)
PyOCR is just looking for tesseract.exe in your os Path variable, so I think you just have to solve the mention issue and it will work.
EDIT 2:
I updated the download link with UB Mannheim version. Seems more efficient on my data. Also, I downgraded to Tesseract 3, because a lot of flags was not supported in 4.0 alpha build.
Hope it can help a little bit,
Best regards
Please check the correct path of installation of Tesseract-OCR. Setting the correct path, i.e. C:\Program Files (x86)\Tesseract-OCR worked for me.
Related
I cannot get autocomplete working for OpenCV (Python) on Windows.
According to Abid's instructions here, I pasted the cv2.pyd file in the C:\Python27\Lib\site-packages.
In the Python code, I import as follows:
import cv2.cv as cv
I have also installed numpy, and it created its own folder in site-packages unlike OpenCV (which I've pasted directly into site-packages).
With this setup, the code executes without any problems, even when OpenCV methods are called.
But I have not been able to get autocomplete to work. I have tried to get it to work on Sublime Text 2 (with SublimeCodeIntel) and PyCharm. In both IDEs, autocomplete works for the numpy import, but fails for the OpenCV import.
I'm using OpenCV 2.4.6, and Python 2.7 (32 bit).
Any possible solutions?
The reason it's not working is because you're using a .pyd file, which is essentially the same as a compiled .dll. Autocomplete works by reading the source .py files, which are plain text. Try installing the OpenCV and Intel Math Kernel Library optimized NumPy packages from Christoph Gohlke's Python Extension Packages for Windows repository, which is frequently updated and a must-use resource for anyone who does any kind of scientific Python computing on Windows. Make sure you delete the cv2.pyd and numpy directories from site-packages first. These new packages will install the .py source files needed by the autocomplete engine in Sublime Text.
EDIT
OK, so I wrote the above because it worked well for a bunch of other packages. I'm a Python 3 guy, and I never installed OpenCV from Gohlke because it only has Python 2 bindings. After reading #CrazyCoder's comment below, I booted up Win7, and indeed he's absolutely correct (and I should have realized this before) - since OpenCV is written in C/C++, the only .py file included in the Gohlke package is cv.py, whose entire contents are as follows:
from cv2.cv import *
The rest is contained in cv2.pyd and a bunch of .dlls. The full OpenCV Windows distribution from opencv.org is a 291 MB download, which expands to 3 GB, and the few .py files in there are involved in building OpenCV, and aren't any good for autocomplete purposes. So, unfortunately, I don't know if there's a solution to your problem at the moment. Just keep the docs handy, and perhaps check out OpenCV Computer Vision with Python from Packt/O'Reilly, published in April 2013.
I've had the same issue with PyCharm when building a custom version of OpenCV on windows. Here is what I did to fix it:
OpenCV made a folder in Python site-packages like so:
opencv site-packages
So what you need to do is just add the python-3.9 folder to your interpreter.
File
Settings...
Python interpreter
Three dots icon next to your interpreter -> Show all...
Select your interpreter and click on the "Show paths for selected interpreter" icon
Add the folder inside the cv2 site-packages
Now import the cv2 module normally.
The best way to solve all the problems of OPENCV-PYTHON is by uninstalling it and reinstalling it.
Even I faced the same problem.
I fixed it by:
python -m pip uninstall Opencv-python
Then I reinstalled it by using a lower version. But unfortunately, I did not know the versions of opencv; So by using a small trick you can get it by running:
python -m pip install opencv-python==
and you will get an error similar to this:
ERROR: Could not find a version that satisfies the requirement opencv-python== (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64) ERROR: No matching distribution found for opencv-python==
Here you can see all the versions of opencv-python; choose any one (but not the latest as the error occurs due the latest version of opencv-python. install it by using:
pip install opencv-python==3.4.17.61 (You can choose your version, but this version solved the issue for me)
then enjoy your coding....
Even AUTO-COMPLETE error in opencv-python gets solved.
HAPPY CODING
I am new to Python so this may be a stupid question, sorry in advance if it is so!
The paths Python searches for modules using Spyder 4.1.4.:
[.., 'D:\Users\Martin\Anaconda3\lib\site-packages', ..]
The paths Python searches for when used via command line in windows:
[.., 'D:\Users\Martin\Anaconda3\lib\site-packages', ..]
Thus, both include path to
'D:\Users\Martin\Anaconda3\lib\site-packages'
where I store my cv2 module installed. Yet, Spyder can import cv2 and to my surprise cmd cannot import cv2 with an error No module named 'cv2'. What am I missing please? Can anyone verify if it works for him in command line please? (I changed/edited the question again to cut unneccessary long talk, though the essence stayed the same, in hope someone could answer).
I solved it. If you have a similar problem, you can check if your case is similar to mine and follow the steps.
I use Spyder and everything works fine. However my goal is to use Python via cmd. This could not be done because Python via cmd could not find my modules.
What I did: After typing python in cmd, Python worked and output its version by default. However, I noticed the version was different than version running in Spyder - I had two Python installations (one of which I didn't know about). I found the installation cmd uses by import sys and print(sys.executable). I uninstalled that Python installation.
Now, typing python in cmd does not do anything, it is an unknown command. Then I followed this guide to add my Python installation to Path (using Windows) by:
My Computer > Properties > Advanced System Settings > Environment Variables >
in System variables, I found "Path", clicked Edit, New, then input my Python installation path D:\Users\Martin\Anaconda3 as well as D:\Users\Martin\Anaconda3\Scripts and D:\Users\Martin\Anaconda3\Library\bin. This solved it for me.
I have compiled and installed OpenCV from source, and it works perfect, importing and using it in IDLE IDE or CMD working well.
But when using PyCharm to import OpenCV, there are no errors, but it is warning me that the function or OpenCV variables, can not find.
It is a screenshot from the PyCharm IDE:
There is a warning that imread() function not found.
In the IDE Settings, I did not find any way to configure the OpenCV, all settings seem OK, one more screenshot:
So this problem caused IDE does not autocomplete or suggest the parameters and so on...
But when running the program, it works well without any problem.
Note: When installing OpenCV with PyCharm IDE add packages, then it is OK. But I need to use the one which is compiled from source and installed locally.
Edit:
This the screenshot of IDLE IDE, which you can see the autocomplete works well.
List of packages:
In this list, there is no cv2, which the other packages in the dir are listed here
I had exactly this problem with OpenCV 4.2.0 compiled from sources, installed in my Conda environment and PyCharm 2020.1.
I solved this way:
Select project interpreter
Click on the settings button next to it and then clicking on the Show paths for selected interpreter
adding the directory containing the .so cv2 library (in my case in the Conda Python library path - e.g. miniconda3/lib/python3.7/site-packages/cv2/python-3.7). In general check the site-packages/cv2/python-X.X directory)
I have just installed Anaconda 5.3 64-bit (Anaconda3-5.3.0-Windows-x86_64) on Windows 10 and am getting this error when trying to run Spyder.
pythonw.exe - Ordinal Not Found
The ordinal could not be located in the dynamic link library C:\Users\username\Anaconda3\Library\bin\mkl_intel_thread.dll.
I used Dependency Walker to view the functions in the DLL and see that ordinal 242 is there. The function associated with ordinal 242 is mkl_blas_zherk.
Could anyone help me fix this or direct me to a resource to help me figure it out myself?
The quick answer:
set CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
I set a user environment variable for this.
The official answer is here.
If you are running Python/IPython from a console, check the priority of libiomp5md.dll using where, i.e.:
where libiomp5md.dll
This may show a few absolute paths (one per line) to different libiomp5md.dll files. A healthy setup should list Anaconda's at the top (e.g. C:\ProgramData\Anaconda3\Library\bin\libiomp5md.dll), and if there are any others listed below, they can be ignored as they have lower priority.
However, if you see a different libiomp5md.dll path at the top, then this will be loaded first, and may conflict with Anaconda's DLLs. If this file is in the current directory, then either change directory to a folder without this file, or (if possible) delete or rename the conflicting DLL file. If it's in a different folder, then you may need to re-arrange your PATH variable to move Anaconda's before other paths.
This is not a proper answer, but for me (having the exact same problem) a workaround was to downgrade "anaconda" to 5.2.0 with the Anaconda Navigator. If that works for you, too, you could start upgrading individual packages to see when the error reappears. Maybe it is a bug in one of the packages, not a problem with our systems.
Edit: Here are some links to similar or related discussions:
entry point mkl_blas_dgem2vu could not be located
https://github.com/spyder-ide/spyder/issues/7357
More edit:
It also helped me to find the following files in "C:\Windows\System32" and rename them (I just appended "_renamed" to the file name).
mkl_core.dll
mkl_def.dll
mkl_intel_thread.dll
If I understand correctly, Python will use those instead of the ones in the Anaconda folder, which can cause problems.
['System32\libiomp5md.dll', 'System32\mkl_core.dll',
'System32\mkl_def.dll','System32\mkl_intel_thread.dll',
'SysWOW64\libiomp5md.dll','SysWOW64\mkl_core.dll','SysWOW64\mkl_intel_thread.dll',
'SysWOW64\mkl_p4.dll', 'SysWOW64\mkl_p4m.dll','SysWOW64\mkl_p4m3.dll',
'SysWOW64\mkl_p4p.dll']
Remove all these dll files from C:\Windows\SysWOW64 and C:\Windows\System32
Just do this and restart the spyder once again and hurrrahhhh!!! ur problem will be solved and spyder will open without showing any ordinal 242 error............just do it it is the only solution..
What fixed this issue for me was to uninstall Amplitube and ActiveState Python. I was receiving this exception while using Anaconda prompt and some NLP packages.
I had the same problem and after trying many solutions, including the above, I finally managed to solve it.
First, open command prompt(Administrator) and input:
set CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
Then, launch the Spyder IDE, always using the command prompt by simply inputting:
spyder
It is important to always launch spyder with the command prompt. If you launch Spyder with the Anaconda Navigator, it will still give you the error message.
Following #Azrael_DD's solution to downgrade to anaconda v5.2.0, you can also do it through a normal console:
conda install anaconda=5.2.0
Another way which Works for me (I deleted all DLL files but the problem continued) was to downgrade ANACONDA to Anaconda3-5.2.0-Windows-x86_64.
I got the installer in this link
Total noob here trying to get OpenCV working on Python through Homebrew. I searched everywhere extensively and couldn't find an answer intelligible to me. 99% of what I have done for this install is blindly follow forum posts, though I am beginning to get an understanding of what all this means.
Installed software:
OS 10.7.4
Xcode 4.4.1
-Command Line Tools
HomeBrew
-Python
-GFortran
-OpenCV
1. write this on first line of .bash_profile and save and restart Mac
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
2. open IDLE located at /usr/local/Cellar/python/2.7.3
.>>> import cv
Traceback (most recent call last):
File "", line 1, in
import cv
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv.py", line 1, in
ImportError: No module named cv2.cv
3. Go to Terminal to check PATH and PYTHONPATH
myname-MacBook-Pro:~ myname$ set
.#edited out unnecessary lines
PATH=/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PYTHONPATH=/usr/local/lib/python2.7/site-packages:
1) What does my PATH need to be? I know its comically out of whack from repeated attempts.
2) Why isnt IDLE using this PYTHONPATH?
3. And most importantly, WHAT DO I NEED TO DO OVERALL TO JUST GET AN ICON, ON MY DOCK, THAT I CAN CLICK, THAT OPENS A PROGRAM, WHERE I CAN CODE WONDERFUL PYTHON WITH MAGNIFICENT OPENCV.
Thank you very much for any help you can send my way. I have been attempting to solve this problem for the last 3 days and would be very very appreciative of any help.
So IDLE is a regluar application not a commandline program that you run from bash, so it's not going to read your .bash_profile or your environment variables like PYTHONPATH.
The good news is, there is a way to get IDLE to recognise new python modules which might be in unusual locations, they just need to be referenced from a place where IDLE expects them to be, which is the site-packages directory. The confusing part is that you probably have more than one version of Python installed since Python is installed by default in Mac OSX and you've also installed it with homebrew (and it looks like you've tried macports as well).
Based on the path in the error, we know that IDLE is looking for the module in /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ which is the homebrew installation.
It looks like you somehow have the cv module there or linked in the site-packages directory but you're missing some other necessary file(s).
I have not installed OpenCV myself, but from the instructions here: http://jjyap.wordpress.com/2014/05/24/installing-opencv-2-4-9-on-mac-osx-with-python-support/ It looks like you need to also symlink the opencv cv2.so file into your site-packages directory from the opencv files you got through homebrew. (note the path for your site-packages directory is different from the instructions in the link).