I am just starting in python and am trying to experiment with cv2, but whenever I try to import it I get the same error:
Import "cv2" could not be resolved
I have tried every possible way of installing it, I have tried
sys.path.append('/usr/local/lib/python39/site-packages)
which I've seen on one of the posts, I have also swapped between versions (tried 3.7). When I try it in pycharm, and I hover ower it because it gives me an error and an option to install it where I get an error named
Non-zero exit code (2)
Pycharm image:
Vscode image:
You're using wrong command to install the library. Always check the command on a website with corresponding package documentation like this one: https://pypi.org/project/opencv-python/
So the command you need will be
pip install opencv-python
if this still doesn't work, try different variations:
pip3 install opencv-python
or
python -m pip install opencv-python
Related
No matter what I install, it's either opencv-python, opencv-contrib-python or both at the same time, I keep getting the "No module named 'cv2'" error. I couldn't find an answer here. Some say that only opencv-python works, others say opencv-contrib-python works. I tried everything but nothing seems to work. I'm trying to use the aruco function and I know it belongs to the contrib module.
Any tip? Thanks
Did you try to restart your code editor? I often need to close the file or whole VScoode and reopen for it to see the library I just installed.
Another problem could be that you're installing cv2 to a python verse that youre not using on your code editor..
If youre using python2.9 on your code editor but you install cv2 on your terminal with "pip3.10 install opencv-python" command, your code editor wont find it
I would recommend using conda and creating a new enviroment. Then try sudo pip3 install opencv-python if youre using python3 or you can try sudo pip install opencv-python if you're using python2. This worked for me.
Another tip is to always check that you have the newest version of pip pip install --upgrade pip
I am having error importing modules in my jupyter notebook when running it on a mac machine after successfully installing them using:
!pip install <library name>.
I try it on several modules and error persists.
for example, when running this code
!pip install pyenchant
I get this:
Requirement already satisfied: pyenchant in
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(3.2.2)
when running :
import enchant
I am getting an error message:
ModuleNotFoundError: No module named 'pyspellchecker'
then try to run this (as I read this could help)
!python -m pip install -U pyenchant
and get that:
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip
I think it has something to do with python path and bash_profile but I do not have an intuition for it.
I do not know if it is helpful/relevant, but I have Pycharm, python, Visual Studio Code and anconda installed on my machine. I am doubting that the problem comes from misalignment between the common configuration files of these programs.
can you please help?
I realize that many has encounter similar issue but their solutions did not help me.
p.s. the issue disappear when I use conda install , but I would like to use pip as it give me access to larger library options.
so Ive been trying to install TensorFlow on my Rasberry Pi 3 (B) running Raspbian Strech using pip, but no matter what I try, I get the same error:
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
tensorflow from https://www.piwheels.org/simple/tensorflow/tensorflow-1.13.1-cp35-none-linux_armv7l.whl#sha256=6c00dd13db0791e83cb08d532f007cc7fd44c8d7b52662a4a0065ac4fe7ca18a:
Expected sha256 6c00dd13db0791e83cb08d532f007cc7fd44c8d7b52662a4a0065ac4fe7ca18a
Got 9d1adf39793da3e45661aadc026f9166e893071f4626bfa863c0ee7867dc63ba
This error always shows up in the middle of installation at random points
I've updated pip and tried using pip3 but none of them work...
This is wat I've tried so far:
sudo python3 -m pip install tensorflow
and
sudo pip3 install tensorflow
Both of them show the same error
I believe that tensorflow can only run on 64-bit python. I would check to see what version of python you are trying to install with.
I'm new to python and have been trying to install some packages with pip. I always get this error message though:
Right now i'm using python3 and virtual environment i.e. "everify"
Any suggestions?
probably because you are using the incorrect package. I think you might need py3dns package since you are using Python 3.
I am getting ImportError : no module named 'requests'.
But I have installed the requests package using the command pip install requests.
On running the command pip freeze in the command prompt, the result is
requests==2.7.0
So why is this sort of error happening while running the python file?
Run in command prompt.
pip list
Check what version you have installed on your system if you have an old version.
Try to uninstall the package...
pip uninstall requests
Try after to install it:
pip install requests
You can also test if pip does not do the job.
easy_install requests
I had this error before when I was executing a python3 script, after this:
sudo pip3 install requests
the problem solved, If you are using python3, give a shot.
One possible reason is that you have multiple python executables in your environment, for example 2.6.x, 2.7.x or virtaulenv. You might install the package into one of them and run your script with another.
Type python in the prompt, and press the tab key to see what versions of Python in your environment.
In Windows it worked for me only after trying the following:
1. Open cmd inside the folder where "requests" is unpacked. (CTRL+SHIFT+right mouse click, choose the appropriate popup menu item)
2. (Here is the path to your pip3.exe)\pip3.exe install requests
Done
if it works when you do :
python
>>> import requests
then it might be a mismatch between a previous version of python on your computer and the one you are trying to use
in that case : check the location of your working python:
which python
And get sure it is matching the first line in your python code
#!<path_from_which_python_command>
Opening CMD in the location of the already installed request folder and running "pip install requests" worked for me. I am using two different versions of Python.
I think this works because requests is now installed outside my virtual environment. Haven't checked but just thought I'd write this in, in case anyone else is going crazy searching on Google.