Pip install python package for current user

2019-08-21 14:18发布

Recently I delete some files related to python 2.7 and now I'm crazy. I want to use pip to install python package for current user rather global user.

➜  ~ where pip
/usr/local/bin/pip

➜  ~ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

In the past, I can install requests easily by pip install requests. But now I have to sudo pip install requests or pip install --user requests.

I think because of pip's location I have to install python package within /Library/Python/2.7/..... As you see, it needs root permission. I know venv can help me but now I want to know how to intall python package for current user.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-21 14:45

Use pip's --user option:

pip install --user package 

According to pip's documentation:

--user

Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%Python on Windows. (See the Python documentation for site.USER_BASE for full details.)

查看更多
登录 后发表回答