【问题标题】:'pip' installs to wrong directory, even though it's set correctly in PATH'pip' 安装到错误的目录,即使它在 PATH 中设置正确
【发布时间】:2019-08-06 03:01:54
【问题描述】:

我的 PATH 有问题,似乎无法在任何地方找到答案。

我在我的 Mac 上使用 virtualenv,当我调用 which pip 时,它确认了这一点 - 但是当我 pip install 任何东西时,它会将它转储到我的“usr/local”路径中。

我在我的 .bash_profile 中添加了 export PATH=/usr/local/bin:$PATH 以确保用户安装的二进制文件优先,但我在我的 VSCode settings.json 中添加了 { "python.pythonPath": "/Virtualenvs/py3/bin/python3.7" } 以确保从那里正确的路径。

更具体地说,调用which pip 返回:

/Users/username/Virtualenvs/py3/bin/pip

但是pip install telegramreturns:

Requirement already satisfied: telegram in /usr/local/lib/python3.7/site-packages (0.0.1)

关于为什么会发生这种情况的任何想法?

【问题讨论】:

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


    【解决方案1】:

    我能够通过添加以下内容来解决我的问题:

    {
        "python.pythonPath": "/Virtualenvs/py3/bin/python3.7",
        "python.linting.pylintEnabled": true,
        "python.linting.enabled": true,
        "[python]": {
    
        },
    

    到: /Users/username/Library/Application Support/Code/User/settings.json 也: /Users/用户名/Virtualenvs/test_env/build/.vscode/settings.json

    这不是一个完美的解决方案,因为每次切换环境时都需要我更改 settings.json 文件。

    如果有人没有答案 - 我很乐意听到。

    【讨论】:

      【解决方案2】:

      尝试 pip --user 将其安装到特定的用户目录

      【讨论】:

      • Pip install —user 或您尝试安装的任何软件包。发回错误
      • 我试过:python3 -m pip install --user /Users/username/Virtualenvs/py3/bin telegrampip install --user /Users/username/Virtualenvs/py3/bin/python3.7 telegrampip install --install-option="--prefix=/Users/username/Virtualenvs/py3/bin/python3.7" telegram 以及我能想到的几乎所有其他组合,导致一系列错误:It looks like a path. File 'Users/username/Virtualenvs/py3/bin/python3.7' does not exist. 到:@987654326 @ 没有任何效果。
      • pip install --user telegram 返回Requirement already satisfied: telegram in /usr/local/lib/python3.7/site-packages (0.0.1)
      • 我也试过重新安装电报,但没有成功。
      • 您是否正确安装了virtualevn?按照这里的指南gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
      猜你喜欢
      • 2016-07-16
      • 2014-10-25
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多