I know this is a problem that’s been asked here before, but I have tried all the solutions I found and not solved it. It’s possible I’m not understanding the solutions, but I have tried my best.
I am teaching myself Python and it is slow going, so I don’t understand a lot yet. I’m using VSCode as an IDE, Python version 3.10, and Windows 10. I only have the Python extension installed for VSCode. My project files are on a flash drive, D. I replaced a couple folder names with [Default Names] in the text below.
I keep trying to debug/run some code in VSCode and the very first line
import numpy as np
gives me the error
Exception has occurred: ModuleNotFoundError - No module named 'numpy'.
But I know that’s not true:
`PS D:-CareerProgrammingPythonCoding[ProjectFolder]> py -m pip install numpy
Requirement already satisfied: numpy in c:users[UserID]appdatalocalprogramspythonpython310libsite-packages (1.23.1)`
I tried the solution of going to
environment variables > system variables > "Path" > edit > new >
c:users[UserID]appdatalocalprogramspythonpython310
as well as
C:Users[UserID]AppDataLocalProgramsPythonPython310Libsite-packages
and
C:Users[UserID]AppDataLocalProgramsPythonPython310Scripts
and I also tried adding a user variable called Python. Nothing appears to have changed as a result of these additions.
Some history if it’s helpful:
I first started by installing Python using the Microsoft Store. I used IDLE for a bit, and I used my command line to install pip and numpy. They worked for a little while. I later installed Visual Studio Code IDE. I ultimately have uninstalled the Microsoft Store version and installed the application from the Python site for Windows instead. I have also uninstalled and reinstalled it several times trying to fix my issues, and same for numpy. I also searched my C drive for "python" and burned everything from the past couple days and reinstalled and repaired it out of desperation. No luck.
I have tried to the best of my ability to uninstall everything and reinstall everything to start fresh, because numpy worked ever so briefly early on in IDLE, I think until I had installed the web download version of Python. I don’t really understand environment variables, so I’m not sure what I’m doing or if I’m doing that wrong, or what needs to be restarted when I try something new, so it’s possible I missed something.
Answers a 10 year old could understand would be appreciated! Or terminology I can easily research for an explanation of how to do it.
3
Answers
Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Also Check 64 bit or 32 bit
Download the latest version
and open the location where you downloaded the NumPy module now press the ‘SHIFT’ key and press right-click on the mouse then a menu will open where you find open PowerShell. open it now PowerShell window opens in the folder now type pip install and the file name and press the TAB button and click enter. then the NumPy module will be installed.
Have Fun
Try adding the variable PYTHONPATH to your system variables and add the following paths to this variable.
C:PATH_TO_YOUR_PYTHON_INSTALL
C:PATH_TO_YOUR_PYTHON_INSTALLDLLs
C:PATH_TO_YOUR_PYTHON_INSTALLLib
C:PATH_TO_YOUR_PYTHON_INSTALLScripts
It should look something like this.
Screenshot of Environment Variables
After you added the variable restart your VS Code and it should work.
I hope this helps.
Ctrl+Shift+P open Command Palette
choose Python:Select Interpreter
Choose the right interpreter