python,更改用户站点目录或使用--user安装setup.py --prefix [英] python, change user site directory or install setup.py --prefix with --user
问题描述
我想像这样以非root用户身份安装python模块
I'd want to install python modules as non-root user like this
$ pip install -I --install-option="--prefix=~/usr" scipy
不幸的是,除非您指定--user
,否则这通常不起作用.但是--user
不能与--prefix
一起使用.仅使用--user
(不使用--prefix
)会安装到~/.local
,由于我维护得很好的~/usr
,并且不想在我的env
中添加更多内容以使~/.local
可用,因此我发现它很丑陋也是.
Unfortunately this usually does not work unless you specify --user
. But --user
can't be used together with --prefix
. Using --user
only (without --prefix
) installs to ~/.local
which I find ugly because I have a well maintained ~/usr
and don't want to add even more stuff to my env
to make ~/.local
usable too.
所以我的问题:
- 如何让
--prefix
和--user
一起用于setup.py,否则在不使用--user
的情况下setup.py如何成功? - 还是可以通过
env
将用户站点目录从~/.local
更改为~/usr
?
- How can I let
--prefix
and--user
work together for setup.py or how else could setup.py succeed without using--user
? - Or can I change the user site directory from
~/.local
to~/usr
somehow byenv
?
推荐答案
要回答第一个问题:
在Greg Ward编写的安装Python模块指南中,我们读到:
In Installing Python Modules guide written by Greg Ward we read:
请注意,各种备用安装方案是相互关联的 独占:您可以传递--user或--home或--prefix和 --exec-prefix或--install-base和--install-platbase,但您不能混用这些组.
Note that the various alternate installation schemes are mutually exclusive: you can pass --user, or --home, or --prefix and --exec-prefix, or --install-base and --install-platbase, but you can’t mix from these groups.
要回答第二个问题:
在同一指南中,有备用安装:用户方案,我们在其中阅读:
In the same guide there's section Alternate installation: the user scheme where we read:
文件将安装到
site.USER_BASE
,其中site.USER_BASE
链接到 https://docs.python. org/2/library/site.html#site.USER_BASE .要求我们在那里查看有关 PYTHONUSERBASE
环境的信息变量:
with site.USER_BASE
linked to https://docs.python.org/2/library/site.html#site.USER_BASE. There we are asked to see also information on PYTHONUSERBASE
environment variable:
定义用户基本目录,该目录用于计算以下内容的路径 用户site-packages目录和Distutils安装路径,用于 python setup.py install --user.
Defines the user base directory, which is used to compute the path of the user site-packages directory and Distutils installation paths for python setup.py install --user.
此外,您可能对家庭计划:
家庭计划"背后的想法是,您建立并维护一个 Python模块的个人存储.该方案的名称来源于 在Unix上使用主"目录的想法,因为对于 Unix用户使其主目录的布局类似于/usr/ 或/usr/local/.
The idea behind the "home scheme" is that you build and maintain a personal stash of Python modules. This scheme’s name is derived from the idea of a "home" directory on Unix, since it’s not unusual for a Unix user to make their home directory have a layout similar to /usr/ or /usr/local/.
这篇关于python,更改用户站点目录或使用--user安装setup.py --prefix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!