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

查看:27
本文介绍了无法在没有 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

同样,如果您的脚本(例如 CGI)需要您自己的 Python 用户版本,您必须明确告诉他们:

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

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

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

您可以更改 PATH 设置,以便在控制台中输入python"即可运行该版本,但对于在不同用户下运行的网络应用程序无济于事.

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天全站免登陆