Import cv2 error but opencv-python is already installed - python

I've been trying to make a project with opencv, so I followed the YouTube video (It's in python), the video told me to go to cmd (win10) and use the command "pip install opencv-python" so that I can use the command import cv2. But the problem is after I did everything it still gave me an error.
I've done some research on it and nothing seem to work. I tried restarting my laptop or reinstall opencv, but nothing works for me. I'm thinking maybe it's because the PATH was wrong so it couldn't access it? But I've never worked with these before so I don't know what I'm supposed to do. I've seen some people with the same problem but the solution doesn't seem to work.
I'm using:
python 3.10.8
windows 10
IDLE Shell 3.10.1

Welcome to Stack Overflow!
Try installing with pip3
pip3 install opencv-python

Related

No module named 'cv2' issue with opencv and contrib modules

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

Problem making Python install praw - syntax error?

Every guide I've found on the web says that all I have to do to install PRAW is type in:
>> pip install praw
However, I've been trying to do that for an hour and it just keeps saying 'invalid syntax'. I tried on windows command prompt, and that doesn't work. I installed PIP when I installed python, but I'm not seeing a python install on my C:\ drive and no matter how many times I reinstall I can't make this work. It's driving me nuts. Does anyone know what I'm doing wrong?
I'm on Windows 10 with the latest version of Python
It turns out I didn't install for PATH. This was easy to miss as it's tiny and on the first installer page. It also didn't totally solve the problem, but did allow me to install PRAW.

Converting a Python file into a desktop application

I've coded a game in Pygame using Pycharm, and I want to make it into a downloadable desktop application so that other people can download and use it even if they do not have python or the necessary files. The problem is I don't know how to. I've heard of py2exe and py2app before. I tried py2exe but then realized that .exe was for windows, and I was using a Mac. I read the py2app documentation, but it was very confusing and hard to understand, and none of the things they said worked. They said to use the pip command to install py2app inside the terminal, but I tried it and it said that it did not recognize the pip command. Can someone please help? Thanks!
Sorry if this question is long. I am trying to tell as much information as possible.
You can use pyinstaller if you package the application in Mac OS it will run on Mac.
Click here for instruction on how to install the package and use it.
Which installation of Python do you use? I had bad experience with Homebrew when it came to packaging, then I've removed it and switched to Python3.9 downloaded directly from python.org and everything works well now.
Depending on your Python installation, it is possible that you don't have pip installed on your computer. Via terminal, you can check it using
python -m pip --version
and you should get a response of this type:
pip X.Y.Z from .../site-packages/pip (python X.Y)
If you don't have pip, you can either re-install Python as mentioned above, or you can just install pip using these instructions.
As soon as you have pip installed, you can install py2app using
pip install py2app

Problem importing modul OpenCV in Anaconda

I am a beginner in terms of using python. Currently, I got python 3.7 and I am using anaconda as IDE. For my project, I need to detect the location and brightness of points/dots in an external imported picture. I figure I could use the modul OpenCV. Unfortunately, I am stuck right now with the problem to import the module cv2. I already successfully installed the package using
python -m pip install OpenCV-python
on command prompt. OpenCV Version which was installed is 4.2.0.34. While compiling the test script of OpenCV on Spyder
import cv2
print(cv2.__version__)
I got this message
"ImportError : DLL load failed : The Modul was not found."
Can somebody let me know please how to fix this problem? Is somehow the version of OpenCV I got not compatible with the Python version? I already watched and followed many tutorial videos on Youtube, but I couldn't find the solution. I tried to copy the cv2.pyd to the site-packages folder in
C:/user/Anaconda3/Lib/site-packages directory
still it didn't fix the problem...
I would appreciate any answers and help I could get here. Thank you!
try installing it using these commands in the following order:
conda update anaconda-navigator
conda update navigator-updater
pip install opencv-python
It should work fine.
Try conda install opencv
or conda install -c menpo opencv

Installed OpenCV not working on PyCharms Python 3.8 project

I know there's a lot of answers related to this question, but I really couldn't find the answer so I'm here.
The problem started when I saw cv2 doesn't import on Python 3.8. So I found there's OpenCV whl file available for Python 3.8, I downloaded the whl file, pip installed into Python 3.8 using command:
python3.8 -m pip install opencv_python-4.1.2.30-cp38-cp38-macosx_10_9_x86_64.whl
I confirmed it works on Terminal I opened Python3.8 and entered command: import cv2
And it imported just fine, but when I try import cv2 on my PyCharm project this message keeps showing:
Error message
I looked everywhere and I really can't find answer anymore. If anyone can help me I would be very thankful.

Categories