vscode中的导入错误,同时可以的终端

时间:2019-02-21 17:09:40

标签: python visual-studio-code python-import vscode-settings

我在xubunutu和python 2.7和3.6.7上有vscode。我也用python 3.6.7制作了virtualenv。在python 3和virtualenv中,我已经安装了matplotlib。但是,当我导入matplotlib并运行代码时,我收到导入错误。更加确定的是,我已经在终端中检查了导入,还可以。 由于我尚未在python2.7中安装matplotlib,因此似乎vscode仍未使用python3,尽管在底部显示python3.6.7。

在crtl + shift + p之后的vscode中,我选择了解释器,还将set.json中的路径更改为相应的地址。例如python 3:

{
"python.pythonPath": "/usr/bin/python3"
}

并为我的virtualenv命名为“ test”:

{
"python.pythonPath": "/home/joudy/test/bin/python"
}

1 个答案:

答案 0 :(得分:0)

您是否检查过状态栏(位于左下角)是否显示了您要使用的正确解释器/环境? (image of the status bar)

如果没有,请遵循official guide,了解如何在VS Code中使用python环境。