【问题标题】:Python 3 on visual studio codeVisual Studio 代码上的 Python 3
【发布时间】:2016-12-12 10:27:40
【问题描述】:

所以我一直在网上寻找如何在 Visual Studio 代码上使用 python 3 编译我的 python 程序。但是,似乎他们没有太多关于如何做到这一点的信息。下面是我的 task.json 文件的样子。我在做什么吗?

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "Python",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}

任何建议都会非常感谢您

【问题讨论】:

  • 有人帮忙解决这个问题吗?
  • 您是否尝试过安装任何扩展? top downloaded python 扩展对我来说已经足够好了。
  • 感谢您的回答。我刚刚检查了一下,我确实安装了用于 VS Code 的扩展 Python。但是我在我的文件中将这个 shebang 指令放在哪里,因为他们提到“要在 Python 2 或 3 上进行指示,shebang 必须出现在 python 文件的顶部!#/usr/bin/python2 或!#/usr/bin/蟒蛇3”?将 !#/usr/bin/python3 放在我的 python 文件之上仍然不能使用 python 3 运行

标签: python python-3.x visual-studio-code


【解决方案1】:

在 VSCode 中,您需要指定要使用特定 Python 版本运行的工作区。

按“Ctrl+Shift+P”并输入“解释器”并选择“Python:选择工作区解释器”

这将列出您机器上安装的不同版本。选择你想要的。

【讨论】:

  • 谢谢@PeeDi!在此期间我一直在使用 pyCharm,因为我找不到方法。
  • 这会在用户设置中设置"python.pythonPath": "/usr/bin/python3"。太好了,谢谢!
猜你喜欢
  • 2021-03-10
  • 1970-01-01
  • 2021-04-14
  • 2016-08-19
  • 1970-01-01
  • 2019-08-02
  • 2021-08-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多