我对VSCode和Python比较陌生,我正试图掌握VSCode如何使用路径变量。我安装了两个版本的Python和一个虚拟环境:
我还有一个保存在文件夹中的相对简单的脚本(standardplot.py):
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()
当我选择虚拟环境时,我可以通过使用VScode中的RunPython file in terminal按钮很好地运行脚本。但是,更改为“正常”环境并再次运行会导致找不到matplot lib模块错误。Matplotlib安装在虚拟和普通环境中。如果我以以下方式从powershell终端运行文件
python standardplot.py
同样有效
如果我只是在VSCode中运行脚本,我不知道为什么它不会运行。。任何帮助都将不胜感激
这似乎是与VS代码配置有关的问题。检查这些文档可能有助于:
Python环境:https://code.visualstudio.com/docs/python/environments
在VS代码中开始使用Python:https://code.visualstudio.com/docs/python/python-tutorial#_select-a-python-interpreter
Visual Studio中的Python代码:https://code.visualstudio.com/docs/languages/python
相关问题 更多 >
编程相关推荐