为当前用户点安装python软件包 [英] Pip install python package for current user
问题描述
最近我删除了一些与python 2.7
相关的文件,现在我疯了.我想使用pip
为当前用户而非全局用户安装python软件包.
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)
过去,我可以通过pip install requests
轻松安装requests
.但是现在我必须sudo pip install requests
或pip install --user requests
.
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
.
我认为由于pip的位置,我必须在/Library/Python/2.7/....
中安装python软件包.如您所见,它需要root权限.我知道venv
可以帮助我,但现在我想知道如何为当前用户安装python软件包.
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.
推荐答案
使用pip
的--user
选项:
pip install --user package
根据 pip
的文档:
--user
安装到您平台的Python用户安装目录.通常是Windows上的〜/.local/或%APPDATA%Python. (有关完整详情,请参见Python文档.site.USER_BASE.)
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.)
这篇关于为当前用户点安装python软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!