When inside my VENV, PIP FREEZE shows I have a package installed but when I run my code, it says module not found


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 environment 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:UsersUserDesktopTouristRoutingProblemTouristRoutingProblem0 classesTouristRoutingProblem.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:UsersUserDesktopTouristRoutingProblemtouristroutingproblemmy_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'>
Asked By: Peek0



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.

enter image description here

Answered By: JialeDu