How to change pip3 path after installing python with homebrew?

北战南征 提交于 2020-02-06 16:14:29

问题


I previously installed Python 3 through the official distribution but recently decided to use Homebrew. I followed this to change my Python 3 path: Homebrew not linking python correctly?

This is how my python 3 path looks (which is what I want):

$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

$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?


回答1:


You need to remove /Library/Frameworks/Python.framework from your PATH. That was added when you installed Python from the official distribution). 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.

In your ~/.bash_profile, try this:

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

then restart your Terminal or source ~/.bash_profile. Homebrew's pip should be in /usr/local/bin, installed along with Homebrew's Python.

That should also have been the fix for the system not using Homebrew's Python.



来源:https://stackoverflow.com/questions/59241087/how-to-change-pip3-path-after-installing-python-with-homebrew

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!