将pip软件包安装到$ HOME文件夹 [英] Installing pip packages to $HOME folder

查看:102
本文介绍了将pip软件包安装到$ HOME文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能吗?安装 pip 时,请在$HOME文件夹中安装python软件包. (例如,我想使用pip安装mercurial,但要在$HOME而不是/usr/local内)

Is it possible? When installing pip, install the python packages inside my $HOME folder. (for example, I want to install mercurial, using pip, but inside $HOME instead of /usr/local)

我在Mac机器上,只是考虑了这种可能性,而不是污染"我的/usr/local,而是使用我的$HOME.

I'm with a mac machine and just thought about this possibility, instead of "polluting" my /usr/local, I would use my $HOME instead.

PEP370 正是关于此的.只是创建一个˜/.local并执行一个pip install package足以使这些软件包仅在我的$ HOME文件夹中安装?

PEP370 is exactly about this. Is just creating a ˜/.local and do a pip install package enough to make these packages to be installed only at my $HOME folder?

推荐答案

虽然可以使用virtualenv,但不需要.诀窍是将PEP370 --user参数传递给setup.py脚本.使用最新版本的pip,一种方法是:

While you can use a virtualenv, you don't need to. The trick is passing the PEP370 --user argument to the setup.py script. With the latest version of pip, one way to do it is:

pip install --user mercurial

这应该导致将hg脚本安装在$HOME/.local/bin/hg中,并将其余的hg软件包安装在$HOME/.local/lib/pythonx.y/site-packages/中.

This should result in the hg script being installed in $HOME/.local/bin/hg and the rest of the hg package in $HOME/.local/lib/pythonx.y/site-packages/.

请注意,以上内容适用于Python 2.6.在Python核心开发人员中,关于Mac OS X上适当的目录位置是什么,有不少争议一点争议.用于PEP370样式的user安装.在Python 2.7和3.2中,Mac OS X上的位置从$HOME/.local更改为$HOME/Library/Python.这可能会在将来的版本中更改.但是,目前,在2.7(和3.2,如果Python 3支持hg)上,上述位置将是$HOME/Library/Python/x.y/bin/hg$HOME/Library/Python/x.y/lib/python/site-packages.

Note, that the above is true for Python 2.6. There has been a bit of controversy among the Python core developers about what is the appropriate directory location on Mac OS X for PEP370-style user installations. In Python 2.7 and 3.2, the location on Mac OS X was changed from $HOME/.local to $HOME/Library/Python. This might change in a future release. But, for now, on 2.7 (and 3.2, if hg were supported on Python 3), the above locations will be $HOME/Library/Python/x.y/bin/hg and $HOME/Library/Python/x.y/lib/python/site-packages.

这篇关于将pip软件包安装到$ HOME文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆