I pip installed several packages (opencv, face_recognition, imutils)
They were all successfully installed, but are not recognized
I have a python script named script.py which imports cv2, but when I run it I get the following:
ModuleNotFoundError: No module named 'cv2'
I tried using pip list command to see the packages I have installed, but the packages I installed are not showing as you can see below.
I run pythonVersion.py to check my python version, it says it's using 3.8.2 which is where my packages are stored, as shown below.
I tried using #!/Users/Khuzama/opt/anaconda3/lib/python3.8 (the path of my packages) in my script, but still the same issue.
I am using jupyter notebook (anaconda navigator)
It is most probably the python environment you installed the packages are not the one you are currently referring to.
Try seeing the output of
which python
if this doesn't point to the anaconda one, then navigate to Users/Khuzama/opt/anaconda3/lib/python3.8 and run your script from there. Alternatively you can link the python from anaconda as the main python for your system
Related
I have installed Python 3.9 on my ubuntu 18.04 desktop, i have already installed two libraries using pip3 install
1)opencv-contrib-python
2)opencv-python
Currently i am writing a program in VSCode for which i am importing cv2
I have already default version of python 3.6.9 in my computer. When i use default version as interpreter, program seems to be working fine.But if i switch the interpreter to newly installed python 3.9 , i get an error
ModuleNotFoundError: No module named 'cv2'
please someone who has faced such problem and know how to resolve it help me!!!...
The reason is as you described: it is due to the use of the Python environment.
The module "cv2" is installed in "lib\site-packages\" in python3.6.9, but when we use "python3.9" without the module "cv2" installed, VS Code is in "python3.9" The module could not be found in "lib\site-packages\".
You could use the command "pip3 --version" to check the source of the module installation tool, the module is installed in "lib\site-packages\" here:
When using the command "pip3 show opencv-python" to check its installation location: (...\python\python38\lib\site-packages)
Therefore, if you want to use the module "cv2" in "python3.9", please install it in this environment. In addition, it is recommended that you use a virtual environment, it will be stored in "lib\site-packages" in the folder of the project so that you could check it more intuitively.
I am trying to install modules like tkinter, bs4 and numpy.
I use cmd and pip to install them, and it says that everything is installed fine.
When I am using Visual Studio code it says
ModuleNotFoundError: No module named '....'
How can I find out if Python and the modules are in the same PATH?
Or what can i do to fix that?
I've tried to reinstall Python, but I get the same error.
Is it just the VSC?
File "c:/Users/Γιώργος Μαργα/Desktop/test.py", line 1, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
pip install is most likely installing globally into a Python interpreter that is different than the one that you have selected in VS Code.
if vscode not recognize your modules try to reload vscode.
install modules with
python3 -m pip install {new_module}
and then reload your Vs code
make sure to set your Python interpreter within VSCode to the same as the one in your system path pythoninvscode
Ok so i uninstall python and installed it again but this time i checked the box that said add that to PATH or someithng like this.
I also uninstalled python from the windowsstore however when it ry to run a code in VSC it doesnt do anything
I was trying to install the python chess module and kept getting the same error: ModuleNotFoundError: No module named 'chess'
I looked at some other code and noticed the same problem of not importing the module even though it worked before (in this case it was from sklearn.model_selection import train_test_split).
I figured the problem was that I put all my code in a new folder. Once I took out all of my code from this folder it was able to work, but the chess module still didn't. This made me think that it must be an issue with the path.
Since I use quite a few folders in order to organize my work. How do I fix this?
I don't want to take out all of my code from every folder I have.
I am using VSCode, and I have already installed the chess module, several times, using pip, pip3, python -m install pip, conda, in the command prompt, terminal in VSCode, and miniconda.
So it is not an installation problem.
You can install module manually,
pip install python-chess
Run this command in virtual environment, this will install python chess module
I have installed dlib using Anaconda 3 prompt.
It has shown me that it got installed successfully. I checked through command import dlib it did not give me any error even I checked the version also it came up with 19.9.0.
But when I open my program in IDLE and run the program its showing me error
import dlib ModuleNotFoundError: No module named 'dlib'
Even from command prompt, I am getting same error.
What is the issue? I am using Python 3.6.
Installation process of dlib using anaconda3:
You have installed the package in different version of python and importing the package in other version of the python.
Package is installed. in virtual environment(3.6.8) and is being imported in standard system python (3.6.0).
So either you need to use this virtual environment for your application otherwise you will need to install the package into global system python.
Extending #Rohit's answer:
As you have installed dlib in Anaconda, you need to run the program using Anaconda prompt.
By default, IDLE and python command in command prompt use Python that is installed system wide (which is Python 3.6.0 in your case).
But to use dlib which is installed in Anaconda's virtual environment (env_dlib) you need to do:
Open Anaconda prompt.
Activate env_dlib environment: activate env_dlib
Run the Python file which uses dlib package: python FILENAME
I am trying to import Python packages that I had previously installed but I keep getting this error when trying to import it
"ImportError: No module named gdal"
In the images attached (in the link :P) you can see that the package python-gdal and python-numpy are installed. I am also attaching the python output.
P.S = I am using Ubuntu and running python from the terminal.
You have possibly installed a non-Ubuntu version of Python - Anaconda - yet these packages are installed into the system Python. You should probably remove Anaconda, and/or run the system Python explicitly as /usr/bin/python.