How to use opencv module in python(I'm using pycharm) [duplicate] - python

This question already has answers here:
Cannot find module cv2 when using OpenCV
(24 answers)
Closed 2 years ago.
Thanks to read my question.
I got homework to print figures and try to use opencv module.
I search internet and download opencv by using cmd.(pip install opencv-python)
But in pycharm, I can't use opencv module.
Error massage tells me
ModuleNotFoundError: No module named 'cv2'
I don't know about programming well, It's hard to me guess reason.
Some theory is my code file is in D drive, not C drive which pycharm or python is install.

If you have python version 3 and above:
pip3 install opencv-python
If you have python version 2 and above:
pip install opencv-python
If you have used these commands and installed the package successfully, there is a good chance that your pycharm is not using the python version that you have installed this package on.
If you just want to be assured that you have installed the package correctly use
pip list
and check if the opencv-python is in the list. If you are seeing this package in the list you should check the version of your pycharm python interpreter.
Checkout this link for more information:
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html

Related

Why python didn't see nltk module? [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 4 months ago.
I cant run my programm because nltk module is missing but i just intstalled it and it just right here in the folder
I tried to reinstall my python, and tried to change python interpreter but nothing worked
How have you actually installed nltk?
You can check if it's actually installed with pip freeze.
What might be happening here is that you could have another version of python installed, so make sure that you actually call the same interpreter for checking and installing with pip, in your case E:/pythonProject1/Scripts/python.exe -m pip freeze and E:/pythonProject1/Scripts/python.exe -m pip install nltk

Error trying to install matplotlib in Windows [duplicate]

This question already has answers here:
Cannot install Matplotlib on Python 3.10
(2 answers)
Closed 1 year ago.
I'm trying to install matplotlib for Python 3.10 in Windows. Im using pip: pip install matplotlib I've already installed NumPy, Cython, Pillow and other libraries needed. But it shows this error:
error: Failed to download any of the following: ['http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz']. Please download one of these urls and extract it into 'build/' at the top-level of the source repository.
I've downloaded the said library and copied it in .cache/matplotlib/build but it doesnt work.
Any idea?
So as #FlyingTeller commented, there are no stable realeses of matplotlib so using --pre fixed the problem.

PyCharm shows ModuleNotFoundError: No module named 'cv2' even though it has been installed successfully [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 1 year ago.
I tried a course on Face Detection using OpenCV and I got stuck on the first step itself because after running the test code, PyCharm shows ModuleNotFoundError: No module named 'cv2'. However I have installed OpenCV successfully using pip install opencv-contrib-python and my pip has been updated to the latest version.
I'm using Windows 10 (64 bits)
Python Version: 3.9.6
Numpy Version: 1.21.1
OpenCV Version: 4.5.3.56
Pip Version: 21.2.2
Code to print the 3D Matrix of a colored image:
import cv2
img = cv2.imread("C:\\Users\\bibhr\\PycharmProjects\\pythonProject2\\lfc.jpg",1)
print(img)
Error Message:
ModuleNotFoundError: No module named 'cv2'
Image for pip list:
enter image description here
I have tried uninstalling and reinstalling Python and OpenCV but none of that worked
Any help would be appreciated as I need to finish this project in a couple of weeks.
Also, I couldn't find cv2.so file in C:\Users\bibhr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cv2
Is that the reason? If yes, then how do I find cv2.so in my computer? (The search box couldn't find it either)
Try to use pip install opencv-python instead of opencv-contrib-python
Hope this will be helpful!
Thanks for the help everyone. I solved the issue by changing the Project interpreter from Virtual Environment to Existing Interpreter.

ModuleNotFoundError, but the package should be there [duplicate]

This question already has answers here:
ModuleNotFoundError: No module named 'requests' after pip install [duplicate]
(2 answers)
Closed 1 year ago.
Here is what I'm using:
Python 3.7.x on PyCharm 2018.2.4
Windows 10.
I'm following a tutorial about website parsing, but the struggle begins before I can even really start out.
I get the error message:
ModuleNotFoundError: No module named 'requests'
The package should be installed properly (pip3 install requests) and I run only that single version of python as far aI i know. I can find the package in the directory I'd expect it to be (C:\Users\Bob\AppData\Local\Programs\Python\Python37\Lib\site-packages).
I expect the same problem for the other package (beautifulsoup4), but the script doesn't even get that "far".
So, I'm aware that I must've done something incorrectly but I can't figure out what.
Any advice?
requests is a module which is needed for the script / the command you are trying to run but seems not to be part of the python installation or the python distribution you choose.
I can guess that you got the error while entering the following line:
>>> import requests
I would run the pip install request command from powershell and try to install the package:
python -m pip install requests
I do not know what you want to use python for but I usually advise to use a python distribution such as Anaconda which contains plenty of additional packages including requests.

Python Data Analysis [duplicate]

This question already has answers here:
Install a module using pip for specific python version
(17 answers)
Closed 5 years ago.
I am new to python. I have various versions of python installed in my Mac.
The pandas is installed in python 3.5. I want to use python 2.7. However when I do
import pandas
It says:
ImportError: No module named pandas
I tried pip install pandas but it is installing in python3.5
Can anyone suggest me how I can install modules for specific python
Tanya
I would suggest you to create a virtual environment and get started with the Python version you want to work on. Link to Documentation
You may also follow easy instructions for getting your choice of Python version on IPython Notebook as well. You may follow Step 1-4 in this documentation for virtual env and Python 2.7

Categories

Resources