无法在没有sudo访问的情况下安装Python [英] Unable to install Python without sudo access

查看:237
本文介绍了无法在没有sudo访问的情况下安装Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提取,配置并使用了make作为服务器中的安装软件包.

I extracted, configured and used make for the installation package in my server.

但是,我不能使用 make install .我得到了错误

However, I could not use make install. I get the error

[~/wepapps/python/Python-2.6.1]# make install
/usr/bin/install -c python /usr/local/bin/python2.6
/usr/bin/install: cannot create regular file `/usr/local/bin/python2.6': Permission denied
make: *** [altbininstall] Error 1

我运行文件夹

chmod +x Python-2.6.1

我仍然遇到相同的错误.

I get still the same error.

如何在没有sudo访问的情况下运行 make install ?

How can I run make install without sudo access?

推荐答案

如何安装到主目录下的路径?

How can I install to a path under my home directory?

mkdir /home/masi/.local

cd Python-2.6.1
make clean
./configure --prefix=/home/masi/.local
make
make install

然后使用:

/home/masi/.local/bin/python

类似地,如果您有需要您自己的Python用户版本的脚本(例如CGI),则必须明确告诉它们:

Similarly if you have scripts (eg. CGI) that require your own user version of Python you have to tell them explicitly:

#!/home/masi/.local/bin/python

而不是使用默认的系统Python(将选择#!/usr/bin/env python").

instead of using the default system Python which "#!/usr/bin/env python" will choose.

您可以更改PATH设置,以使仅从控制台键入"python"即可运行该版本,但对于在其他用户下运行的Web应用程序无济于事.

You can alter your PATH setting to make just typing "python" from the console run that version, but it won't help for web apps being run under a different user.

如果编译链接到Python的内容(例如mod_wsgi),则必须告诉它在哪里可以找到Python,否则它将使用系统之一.通常这样做是这样的:

If you compile something that links to Python (eg. mod_wsgi) you have to tell it where to find your Python or it will use the system one instead. This is often done something like:

./configure --prefix=/home/masi/.local --with-python=/home/masi/.local

对于其他基于setup.py的扩展,例如MySQLdb,您只需使用正确版本的Python运行setup.py脚本即可:

For other setup.py-based extensions like MySQLdb you simply have to run the setup.py script with the correct version of Python:

/home/masi/.local/bin/python setup.py install

这篇关于无法在没有sudo访问的情况下安装Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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