I am really at my wit's end right now. After creating a venv, activating it and installing a few packages (Numpy), when I run my code which has "import numpy as np", it throws an error saying module not found. I did a PIP FREEZE in the cmd while still in the environemnt and it shows me the version of Numpy that is installed.
I am very confused why this is the case, I have deleted and recreated the environment multiple times to no avail.
Doing pip list
and pip freeze
shows this
Package Version
---------- -------
numpy 1.23.0
Running my program which has the line import numpy as np
results in this error
Traceback (most recent call last):
File "c:\Users\User\Desktop\TouristRoutingProblem\TouristRoutingProblem\00 classes\TouristRoutingProblem.py", line 2, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Curiously, when I run the following in the CMD this happens.
(my_env) PS C:\Users\User\Desktop\TouristRoutingProblem\touristroutingproblem\my_env> python
Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> print(np)
The output is as follows, which suggests that numpy IS installed.
<module 'numpy' from 'C:\\Users\\User\\Desktop\\TouristRoutingProblem\\touristroutingproblem\\my_env\\lib\\site-packages\\numpy\\__init__.py'>
CodePudding user response:
Use the Ctrl Shift P command to open the Command Palette, search for and select Python:Select Interpreter(Or click directly on the python version displayed in the lower right corner), and select the correct interpreter.
CodePudding user response:
I had same issue when I was installing Opencv when I restarted my pc it worked fine for me. May be help you.