在vscode导入错误同时它是好的终端

问题描述 投票:0回答:1

我在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。

在ctrl + shift + p之后的vscode中,我选择解释器,并将setting.json中的路径更改为相应的地址。例如对于python 3:

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

并为我的virtualenv命名为“测试”:

{
"python.pythonPath": "/home/joudy/test/bin/python"
}
python visual-studio-code python-import vscode-settings
1个回答
0
投票

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

如果没有,请关注如何在VS Code中使用python环境的official guide

© www.soinside.com 2019 - 2024. All rights reserved.