【问题标题】:import error in vscode meanwhile it is ok terminal在 vscode 中导入错误,同时它是好的终端
【发布时间】:2019-02-21 17:09:40
【问题描述】:

我在 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中,我选择了解释器,并将setting.json中的路径更改为相应的地址。例如对于 python 3:

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

对于我的名为“test”的虚拟环境:

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 是的。它正确显示了python的版本,但在选择虚拟环境时不显示。
    猜你喜欢
    • 2016-06-28
    • 2019-09-02
    • 2022-12-03
    • 2018-06-13
    • 1970-01-01
    • 2022-08-03
    • 2022-07-30
    • 2020-07-05
    • 1970-01-01
    相关资源
    最近更新 更多