工作区包含 Pipfile 但未找到 pipenv

Workspace contains Pipfile but pipenv was not found

我在 Mac 上使用 VScode 和 pyenv。但是每次打开工作区时,我都会收到以下消息:

Workspace contains Pipfile but pipenv was not found. Make sure pipenv is on the PATH.

我的 pipenv 已安装,可以在 VScode 上使用终端找到。

>which pipenv
/Users/name/.pyenv/shims/pipenv

所以我将python.pipenvPath设置更改为/Users/name/.pyenv/shims。这次我得到了:

Workspace contains Pipfile but '/Users/user/.pyenv/shims' was not found. Make sure '/Users/user/.pyenv/shims' is on the PATH.

这是因为当前工作区找不到您的 pipenv 路径。所以在 .vscode 下创建一个 settings.json 并指向正确的 pipenv 路径。

要查找 pipenv 路径,请转到包含 pipenv 文件的文件夹,

pipenv --py /Users/[username]/.local/share/virtualenvs/[app-NVz65APH]/bin/python

然后修改settings.json:

"python.pythonPath": "/Users/[username]/.local/share/virtualenvs/[app-NVz65APH]/bin/python",