【问题标题】:PIP installation for Python3 problem: Consider adding this directory to PATHPython3 问题的 PIP 安装:考虑将此目录添加到 PATH
【发布时间】:2020-07-16 10:59:26
【问题描述】:

我尝试通过终端在python $ python get-pip.py 中安装pip,但在终端中出现此警告。

Python3.8
macOS 卡塔利娜

请帮忙 :( 。我一直在寻找答案好几天

WARNING: The scripts pip, pip3 and pip3.8 are installed in '/Library/Frameworks/Python.framework/Versions/3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

【问题讨论】:

  • 你为什么要安装 pip?它通常包含在每个 python 安装中。通常如果你想安装一个包,例如numpy 可以直接调用 python -m pip install numpy。
  • export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin" 添加到您主目录中的.bash_profile 文件中。从终端:$ echo -e 'export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin"' >> $HOME/.bash_profile
  • 谢谢它解决了我的问题:)

标签: python path pip installation


【解决方案1】:

如果您使用的是 Raspberry Pi(Raspbian 操作系统),请执行以下操作:

nano /home/pi/.profile

在文件末尾添加:

# set PATH to pip
PATH="$HOME/pi/.local/bin:$PATH"

Ctrl+X, Y, Enter

然后重新启动您的 Raspberry Pi 以应用更改。

您现在可以通过 pip --version 查看

【讨论】:

    【解决方案2】:

    您需要在系统根目录中添加.bash_profile.zshrc

    export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:$PATH
    

    【讨论】:

    • 欢迎来到 Stack Overflow。请阅读How to Answer。这与 10 票赞成的现有答案有何不同?
    • 如果您使用的是 Raspberry Pi (Raspbian OS),请执行以下操作: nano /home/pi/.profile 在文件末尾添加: # 将 PATH 设置为 pip PATH="$HOME/pi/.local/bin:$PATH"
    【解决方案3】:

    您收到此错误是因为缺少从您的 PATH 安装 pip 的位置。

    你需要添加:

    export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin"
    

    到你的.bash_profile 结尾,就像@hoefling 评论的那样。

    【讨论】:

    • 如何为 Ubuntu 执行此操作
    • @uber 将该行添加到 /home/user/.bashrc 文件中 .bashrc 文件的末尾。您可以使用您选择的编辑器。在终端中运行 gedit /home/user/.bachrc 并在末尾添加该行。注意:在前面的命令中,将 user 替换为您的用户名
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-04
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    相关资源
    最近更新 更多