简体   繁体   中英

Python module error in vs code even though installed properly

I'm using VSCode with code runner and have installed numpy, however, when I try to run it with code runner I get the message: No module named 'numpy' . I looked into my settings.json and the command for python is python3 -u and when executing the respective file with python3 -u file.py in the terminal, everything works fine. What could cause the problem on the side of VSCode?

It is recommended that you use the command ( python --version or pip --version ) to check whether the python currently used in the terminal is the same as the one in the lower left corner of VS Code. And clean up the terminal information, and then re-run the code:

在此处输入图像描述

在此处输入图像描述

In addition, please try to comment out the settings related to "code runner" in "settings.json" and reload VS Code.

Update:

For the problem that the python used in the terminal is different from the python displayed in the lower left corner of VS Code:

If you are using the global python environment , please try to change the first of the python environment variables to the python you want to use, and then reopen VS Code.

在此处输入图像描述

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