如何在没有root用户访问权限的情况下安装python模块? [英] How to install python modules without root access?
问题描述
我正在上一些大学课程,并且得到了一个教学帐户",这是我可以用来从事工作的学校帐户.我想在那台机器上运行需要大量计算的Numpy,matplotlib,scipy代码,但是由于我不是系统管理员,所以无法安装这些模块.
I'm taking some university classes and have been given an 'instructional account', which is a school account I can ssh into to do work. I want to run my computationally intensive Numpy, matplotlib, scipy code on that machine, but I cannot install these modules because I am not a system administrator.
如何安装?
推荐答案
在大多数情况下,最好的解决方案是依靠所谓的用户站点"位置(请参见
In most situations the best solution is to rely on the so-called "user site" location (see the PEP for details) by running:
pip install --user package_name
以下是我原始答案中更手动"的方式,如果上述解决方案适合您,则无需阅读.
Below is a more "manual" way from my original answer, you do not need to read it if the above solution works for you.
通过easy_install,您可以执行以下操作:
With easy_install you can do:
easy_install --prefix=$HOME/local package_name
将安装到
$HOME/local/lib/pythonX.Y/site-packages
(本地"文件夹是许多人常用的典型名称,但是您当然可以指定您有权写入的任何文件夹).
(the 'local' folder is a typical name many people use, but of course you may specify any folder you have permissions to write into).
您将需要手动创建
$HOME/local/lib/pythonX.Y/site-packages
并将其添加到您的PYTHONPATH
环境变量中(否则easy_install会抱怨-btw运行上面的命令一次,以找到X.Y的正确值).
and add it to your PYTHONPATH
environment variable (otherwise easy_install will complain -- btw run the command above once to find the correct value for X.Y).
如果您不使用easy_install
,请寻找一个前缀选项,大多数安装脚本都允许您指定一个.
If you are not using easy_install
, look for a prefix option, most install scripts let you specify one.
通过点子可以使用:
pip install --install-option="--prefix=$HOME/local" package_name
这篇关于如何在没有root用户访问权限的情况下安装python模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!