VS代码设置,找不到python 3

2024-05-19 03:22:23 发布

您现在位置:Python中文网/ 问答频道 /正文

几个世纪以来,我一直试图让vscode工作,现在看来,但我似乎无法让它工作。我在vscode上安装了python扩展

这是settings.json

{
"python.pythonPath": "/usr/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"workbench.settings.editor": "json",
"workbench.settings.useSplitJSON": true
}

这是我的python路径

python3: /usr/bin/python3.8 /usr/bin/python3.8-config /usr/bin/python3 /usr/lib/python3.8 /usr/lib/python3 /etc/python3.8 /etc/python3 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python3 /usr/share/man/man1/python3.1.gz

这是helloworld程序的错误

[Running] python -u "/home/hbahsir/Documents/Python Scripts/hello.py"
/bin/sh: 1: python: not found

[Done] exited with code=127 in 0.009 seconds

我想让vscode工作,但我做不到

编辑:我使用的是linux系统


Tags: jsontruesharebinsettingslibusretc
2条回答

对我有用的东西

备选方案1(简易方式): 安装python-is-python3

(安装命令)sudo apt-get install python-is-python3

备选方案2(更快的方式): 制作别名

  1. 在终端中运行gedit ~./bashrc
  2. 转到文件末尾并添加这两行

alias python=python3

alias pip=pip3

然后保存并关闭文件并重新启动终端

该错误仅仅意味着python不存在于环境变量中。您的python3确实指向一个PYTHONPATH,这就是它在您的终端中工作的原因。那么你能做什么-make 'python' program command execute Python 3

如果没有,请尝试以下操作

似乎python作为默认值使用的vscode无法解析为任何解释器。您可以通过执行以下操作尝试更改:

您可以从command palette中选择解释器。以下说明来自DonJayamanne's Github

Select the command Python: Select Workspace Interpreter from the command palette

Upon selecting the above command a list of discovered interpreters will be displayed in a quick pick list

从中选择一个与当前活动的解释器不同的解释器,并查看是否解决了该问题

Command Pallet Screenshot

相关问题 更多 >

    热门问题