我的PATH出了问题,似乎无法在任何地方找到答案。
我在我的Mac上使用了virtualenv,当我打电话给which pip
时,它确认了这一点 - 但是当我对任何东西进行pip install
时,它会把它转移到我的'usr / local'路径中。
我将export PATH=/usr/local/bin:$PATH
添加到我的.bash_profile中以确保用户安装的二进制文件优先,但我在我的VSCode settings.json中添加了{
"python.pythonPath": "/Virtualenvs/py3/bin/python3.7"
}
以确保从那里开始正确的路径。
更具体地说,调用which pip
返回:
/Users/username/Virtualenvs/py3/bin/pip
但pip install telegram
returns:
Requirement already satisfied: telegram in /usr/local/lib/python3.7/site-packages (0.0.1)
有关为什么会发生这种情况的任何想法?
尝试使用pip --user将其安装到特定的用户目录
我能够通过添加以下内容来解决我的问题:
{
"python.pythonPath": "/Virtualenvs/py3/bin/python3.7",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"[python]": {
},
to:/ Users / username / Library / Application Support / Code / User / settings.json以及:/Users/username/Virtualenvs/test_env/build/.vscode/settings.json
这不是一个完美的解决方案,因为每次切换环境时都需要我更改settings.json文件。
如果有人有答案不会 - 我很乐意听到。