简体   繁体   English

使用自制软件安装python后如何更改pip3路径?

[英]How to change pip3 path after installing python with homebrew?

I previously installed Python 3 through the official distribution but recently decided to use Homebrew.我之前通过官方发行版安装了 Python 3,但最近决定使用 Homebrew。 I followed this to change my Python 3 path: Homebrew not linking python correctly?我按照这个来改变我的 Python 3 路径: Homebrew not Linking python 正确吗?

This is how my python 3 path looks (which is what I want):这就是我的 python 3 路径的外观(这是我想要的):

$which python
/usr/local/bin/python
$python --version
Python 3.7.5

However, now pip is using the official distribution but I want to change it to the Homebrew version但是,现在 pip 正在使用官方发行版,但我想将其更改为 Homebrew 版本

$which pip
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip

$pip --version
pip 19.3.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)

How do I change my pip path to the Homebrew version and remove the official distribution safely?如何将我的 pip 路径更改为 Homebrew 版本并安全地删除官方发行版?

You need to remove /Library/Frameworks/Python.framework from your PATH .您需要从PATH删除/Library/Frameworks/Python.framework That was added when you installed Python from the official distribution).这是在您从官方发行版安装 Python 时添加的)。 Or, at least not put it at the beginning, so that Homebrew's Python (the one in /usr/local/bin ) will be the one used by your system.或者,至少不要把它放在开头,这样 Homebrew 的 Python(在/usr/local/bin中的那个)将是你的系统使用的那个。

In your ~/.bash_profile , try this:在你的~/.bash_profile ,试试这个:

export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

then restart your Terminal or source ~/.bash_profile .然后重新启动您的终端或source ~/.bash_profile Homebrew's pip should be in /usr/local/bin , installed along with Homebrew's Python. Homebrew 的pip应该在/usr/local/bin ,与 Homebrew 的 Python 一起安装。

That should also have been the fix for the system not using Homebrew's Python.这也应该是不使用 Homebrew 的 Python 的系统的修复程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM