Issue
I'm writing some python in a venv but it won't let me import numpy even though it is installed... I can see in the venv folder that PyQt and NumPy are BOTH installed and in the library, and pip tells me this as well, but it doesn't let me import numpy, even though PyQt, which is in the same venv library, is able to be imported into Vscode!
It even works when I import it in the shell, but not in the actual class...
Also, numpy is not only installed in the venv, but it is also installed on my actual system as well.
Does anyone know what may be causing this?
Solution
According to the information you provide, it is recommended that you refer to the following two aspects:
The use of python environment.
Please use the command "
pip --version
" or "python --version
" in the VS Code terminal to check whether the python environment used by the current terminal is the same as the python in the lower left corner of VS Code.(If they are not the same, please use the shortcut key Ctrl+Shift+` to open a new VS Code terminal, it will automatically enter the selected environment.)
In addition, for virtual environments, please make sure that the terminal has activated this environment.
Please check the installation package of the module. You could use the command "
pip show numpy
" to view the location of the module "numpy" in this environment, then find the module folder and delete it, and then reinstall it, so as to avoid the damage or incompatibility of the internal files of the module. (The modules recognized by VS Code are stored in "lib\site-packages
" in the python environment used.)
Answered By - Jill Cheng Answer Checked By - Willingham (WPSolving Volunteer)