Opencv import issue in windows 10 [duplicate] - python

This question already has answers here:
How do you fix "runtimeError: package fails to pass a sanity check" for numpy and pandas?
(9 answers)
Closed 2 years ago.
I have an issue with OpenCV in windows 10. Whenever I try to import OpenCV I get following error.
import cv2
** On entry to DGEBAL parameter number 3 had an illegal value
** On entry to DGEHRD parameter number 2 had an illegal value
** On entry to DORGHR DORGQR parameter number 2 had an illegal value
** On entry to DHSEQR parameter number 4 had an illegal value
Traceback (most recent call last):
File "C:\Users\Krishhnandu\AppData\Roaming\Python\Python39\site-packages\numpy\__init__.py", line 305, in <module>
_win_os_check()
File "C:\Users\Krishhnandu\AppData\Roaming\Python\Python39\site-packages\numpy\__init__.py", line 302, in _win_os_check
raise RuntimeError(msg.format(__file__)) from None
RuntimeError: The current Numpy installation ('C:\\Users\\Krishhnandu\\AppData\\Roaming\\Python\\Python39\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Krishhnandu\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 5, in <module>
from .cv2 import *
ImportError: numpy.core.multiarray failed to import
Any help will be appreciated. Thanks.

Python 3.9 is very new you should go back to 3.86 and write this in cmd
pip install opencv

First, you can find help here: How do I install opencv using pip?
Then, try the following steps:
Downgrade your current python version to python 3.8. Go there for more informations: how can I downgrade from python 3.7 to 3.6 in windows. You can also create a virtual environment with python 3.8: https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/26/python-virtual-env/
Type this command line in cmd: pip install opencv-python
Check if opencv package is installed: python -c "import cv2"
For step 2, be sure your pip version is updated.
I hope it'll help you =)

Related

Using pytesseract on Python 2.7 and Windows XP [duplicate]

This question already has answers here:
f-strings giving SyntaxError?
(7 answers)
Closed last month.
I need OCR for a certain project, after searching online I decided to use python and tesseract. Right now I am trying to run the following code just to see if it works:
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
print(pytesseract.image_to_string(Image.open("C:\Documents and Settings\Yerutnik\Desktop\file.bmp")))
However, I am getting the following error:
Traceback (most recent call last):
File "C:\Documents and Settings\Yerutnik\Desktop\test1.py", line 2, in <module>
import pytesseract
File "C:\Python27\lib\site-packages\pytesseract\__init__.py", line 2, in <module>
from .pytesseract import ALTONotSupported
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 89
f"{tesseract_cmd} is not installed or it's not in your PATH."
^
SyntaxError: invalid syntax
I am running this on a Windows XP 32bit machine (must use this machine), Python 2.7.9, Tesseract 4.0.0 (tested working separately in cmd, and I checked that it is in PATH).
you use pytesseract for python3 (f-string is python3 feature) in python2.7 Try some old version of pytesseract.
I was able to fix this by downgrading pytesseract (as suggested by user898678) from 4.0.0 to 0.2.2, upgrading pip from 1.5.2 to 20, and installing pytesseract from web instead of using a wheel file.

Why i cant install the numpy package using pip on Ubuntu 16.04? [duplicate]

This question already has answers here:
Installing pip is not working in python < 3.6
(6 answers)
Closed 2 years ago.
Im trying to install the numpy package with python3 (python --version returns Python 3.5.2), but it doesnt work. Somebody can help me please with this problem? When i use the command
pip install numpy
, the terminal return to me
Traceback (most recent call last):
File "/home/fabricio/.local/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
I've tried install using Python2.7 but it was dreprecation
You have, mysteriously, a version of pip that is using f-strings, such as f"ERROR: {exc}", even though f-strings were not introduced until Python 3.6. Furthermore, recent versions of NumPy support Python 3.7 and above.
Try installing a more recent version of Python3, activating a virtual environment, and installing with python3 -m pip install numpy.
Python 3.5 is also EOL as of 2020-09-30.

Failed to "import gurobipy" after running setup.py or pysetup.bat

After typing "import gurobipy", this would show up:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\1\AppData\Local\Programs\Python\Python38\lib\site-packages\gurobipy\__init__.py", line 1, in <module>
from .gurobipy import *
ImportError: DLL load failed while importing gurobipy: 找不到指定的模块。(EN:The specified module could not be found)
I've tried uninstalling and reinstalling python and gurobi, and made sure both are the 64 bits version.
There is a new Windows safety feature that changes how DLLs are loaded in Python 3.8 and that affects the installation of Gurobi.
You need to tell Python how to find the library again. This can be done either by
copying the gurobi90.dll from gurobi901\win64\bin\ to PYTHON_INSTALLATION_PATH\lib\site-packages\gurobipy\ or by
specifying how the library can be found within the current Python environment:
import os
os.add_dll_directory(os.path.join(os.getenv('GUROBI_HOME'), 'bin'))
The Anaconda Python distribution is not affected by this change and the installation works as intended.
note: This is only affecting Gurobi 9.0.1.

No module named 'index' after install pyflann

I have some problems installing pyflann in python 3.7.3, after execute:
pip install pyflann
The installation is successfully accomplished, but when I import the library and a run a python program, I got this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Anaconda3\lib\site-packages\pyflann\__init__.py", line 27, in <module>
from index import *
ModuleNotFoundError: No module named 'index'
I'm using window 10. How can I fixed?
pyflann does not have support for python 3 yet, according to this GitHub issue. Your two options are:
Install the pyflann-py3 package:
pip install pyflann-py3
Or, you could take the advice from the issue and use 2to3:
sudo 2to3 -w D:\Anaconda3\lib\site-packages\pyflann
The pyflann package is not compatible with Python 3. It looks like
it is not actively maintained, the last commit was in February 2017:
https://github.com/primetang/pyflann/commits/master
There is an open issues documenting the problem:
https://github.com/primetang/pyflann/issues/1
There are a few open PRs trying to add Python 3 support that were never
merged:
https://github.com/primetang/pyflann/pulls
You might have better luck with one of the forks, but I can't vouch for them,
I've never used pyflann:
https://github.com/primetang/pyflann/network/members

Python3 ImportError: No module named '_tkinter' [duplicate]

This question already has answers here:
python ImportError: No module named Tkinter
(5 answers)
Closed 4 years ago.
On my Linux Mint 18, I've tried to install Python 3.6.1 beside my 3.5.2.
With these commands:
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xJf Python-3.6.1.tar.xz
cd Python-3.6.1
./configure
make
make install
The installation was successfully but, now, every time I try to import tkinter, I have the same error:
>>> from tkinter import tk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
I've no idea how to get rid of this issue, and how remove the 3.6.1
I think you still need to install the tkinker package. You can do this by simply typing:
sudo apt-get install python3-tk
The issue as I see is that you are still calling your python3.5 binaries which might be set as default python interface. See the line in your error which tells the version of python it is referring to:
/usr/local/lib/python3.5/tkinter/
If it's a UNIX / Linux flavour you are using, you can check where are your python binaries by using
whereis python
and you will get a list of all the flavours and places it is in:
You simply call out your chosen flavor to work with, which I am guessing might be
/usr/local/bin/python3.6
and then list the available modules to check if Tkinter is available or not, although it is highly unlikely not to as it comes bundled as a standard library.
If you are using pycharm then you can simply write:
from tkinter import *

Categories