问题描述
我想像这样以非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:
要回答第二个问题:
在同一指南中,有备用安装:用户方案,我们在其中阅读:
In the same guide there's section Alternate installation: the user scheme where we read:
,其中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:
此外,您可能对家庭计划:
这篇关于python,更改用户站点目录或使用--user安装setup.py --prefix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!