简体   繁体   中英

All import statements suddenly break in all files

I was cloning a github repository in github desktop, then moved the cloned file into a more convenient location. I then ran the github repository and I got an error message: "ModuleNotFoundError: No module named 'numpy". I thought this was odd, as i had already installed numpy and use it regularly. I then went into a different python file, which used numpy and i was just using before perfectly fine, and tried to run it. I got the same error again.

It seems that all my imports in every single python file i have, in every location, no longer work. To verify that they are still installed, i ran: "pip install numpy", to which i got "Requirement already satisified". Does anyone know what has happened? Python code without any imports works fine, just anything which requires a library is broken.

EDIT: It seems the error only occurs in vscode - when i open a file with the python IDE it works fine, but vscode cant find the module.

Check if there is a virtual environment (like topsail said). numpy might have been installed in a virtual environment.

If there is a virtual environment, check for a Scripts folder or a bin folder. If you find one, run activate or activate.bat .

edit: I guess I was too late to answer lol

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM