无法在VSCode中设置PYTHONPATH环境变量。

huangapple go评论52阅读模式
英文:

cannot setup PYTHONPATH environmental variable in vscode

问题

I tried to set up PYTHONPATH 环境变量在Mac上的vscode中,但没有成功。VScode版本:版本:1.78.1(通用),Mac OS:13.3.1(a)
我按照以下指南操作:
https://code.visualstudio.com/docs/python/environments#_use-of-the-pythonpath-variable
在工作区设置的setting.json文件中

{
    "workbench.colorCustomizations": {
        "editorLineNumber.foreground": "#00ff00"
    },
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "${workspaceFolder}/src",
        "ABC": "124"
    }
}

在终端中,我输入

echo $PYTHONPATH

返回:

/usr/local/Cellar/apache-spark/3.3.2/libexec/python/

然后我在用户的setting.json文件中设置了PYTHONPATH,如下所示

{
    "terminal.integrated.defaultProfile.osx": "bash",
    "terminal.integrated.inheritEnv": false,
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "${workspaceFolder}/src"
    }
}

我关闭了vs code并重新打开,然后输入

echo $PYTHONPATH

得到相同的结果。

我还在工作区的.env文件中设置了PYTHONPATH

PYTHONPATH=/Users/{user_name}/gitlab/aws/dummy_project

但也没有成功。

有人能帮忙吗?

英文:

I tried to set up PYTHONPATH environmental variable in vscode in Mac, and it does not work. VScode version: Version: 1.78.1 (Universal), Mac os: 13.3.1 (a)
I followed the instruction:
https://code.visualstudio.com/docs/python/environments#_use-of-the-pythonpath-variable
In workspace setting.json

{
    "workbench.colorCustomizations": {
        "editorLineNumber.foreground": "#00ff00"
    },
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "${workspaceFolder}/src",
        "ABC": "124"
    }
}

In the terminal, I type

echo $PYTHONPATH

and it returns:

/usr/local/Cellar/apache-spark/3.3.2/libexec/python/

I then set PYTHONPATH in user settint.json like this

{
    "terminal.integrated.defaultProfile.osx": "bash",
    "terminal.integrated.inheritEnv": false,
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "${workspaceFolder}/src"
    }
}

I closed vs code and reopened, and type

echo $PYTHONPATH

and got same result.

I also set PYTHONPATH in .env right under workspace

PYTHONPATH=/Users/{user_name}/gitlab/aws/dummy_project

it does not work either.

Can anyone help on this?

答案1

得分: 1

我发现我在.bash_profile中定义了以下内容:

export PYTHONPATH={some value}

在我注释掉这一行后,terminal.integrated.env.osx 的设置生效。

英文:

I found I define

export PYTHONPATH={some value}

in .bash_profile. After I commenting this line, setting in terminal.integrated.env.osx works.

答案2

得分: 0

在VSCode中配置Python路径的步骤:
图片描述见链接

然后添加python.exe路径 图片描述见链接

英文:

steps to configure the python path in vscode:
enter image description here

enter image description here

Then add python.exe path enter image description here

huangapple
  • 本文由 发表于 2023年5月11日 01:29:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76221159.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定