在 Debian Linux 服务器上安装新版本的 python [英] Installing new version of python on Debian Linux server

查看:42
本文介绍了在 Debian Linux 服务器上安装新版本的 python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 ssh 连接到运行 Debian Linux(版本 6.0.2)的服务器来运行我的 python 脚本.服务器上安装的python版本是2.6.6.它安装在 /usr/bin/python2.6 中(并以符号方式链接到 /usr/bin/python).我对 Linux 很陌生.我想在服务器上安装 python 2.7.8 而不影响服务器的其他用户,并且以一种透明的方式.做这个的最好方式是什么?我的想法是安装在 /usr/bin/python2.7 中,以便我可以使用以下方式运行我的脚本:

I ssh to a server running Debian Linux (Release 6.0.2) to run my python scripts. The python version installed on the server is 2.6.6. It is installed in /usr/bin/python2.6 (and symbolically linked to /usr/bin/python). I'm very new to Linux. I want to install python 2.7.8 on the server without effecting, and in a way transparent, to other users of the server. What is the best way to do this? My idea was to install in /usr/bin/python2.7 so that I can use run my scripts as below:

$python2.7 myScript.py

但我并不完全清楚这样的安装会如何影响其他用户.另外,如果我想安装软件包(如 cv2),我应该如何为我的 python 版本安装它

But I'm not fully aware how such an installation will effect other users. Also if I want to install packages (like cv2) how should I go about doing it for my version of python

推荐答案

我觉得你最好在你的home目录下编译python 2.7.8来安装.这对其他人来说绝对清楚.'update-alternatives' 命令使系统默认 python 版本发生变化.

I think you'd better to install with compiling python 2.7.8 in your home directory. That's definitely clear for the others. 'update-alternatives' command makes system default python version change.

就我而言,我在我的帐户中创建了隐藏目录.opt".然后从 python.org (https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz) 使用以下命令.

In my case, I made hidden directory '.opt' on my account. Then downloaded and extracted source code from python.org (https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz) with below command.

$ cd $HOME
$ mkdir -p .opt
$ wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
$ tar zxvf Python-2.7.8.tgz

它将在您的帐户主页上创建 Python-2.7.8 目录.所以更改目录 Python-2.7.8.

It'll make Python-2.7.8 directory on your account home. So change directory Python-2.7.8.

$ cd Python-2.7.8

请使用前缀"选项进行配置.就我而言,'--prefix=$HOME/.opt'.

Please configure with 'prefix' option. In my case '--prefix=$HOME/.opt'.

$ ./configure --prefix=$HOME/.opt

它将在您的主目录中进行配置.之后,您可以制作"和制作安装".

It'll be configured with setting at your home directory. After than you can 'make' and 'make install'.

$ make && make install

如果没有错误,您可以在 .opt 目录中找到 python 二进制文件的目录.$HOME/.opt/bin/python 是新的.请在 .bashrc 或 .profile 中的配置文件中设置路径环境变量.

If there are no errors, you can find directories for python binaries in .opt directory. $HOME/.opt/bin/python is new one. Please set path environment variable in your profile in .bashrc or .profile.

$ echo "export PATH=$HOME/.opt/bin:$PATH" >> $HOME/.bashrc

它仅适用于您的帐户.

这篇关于在 Debian Linux 服务器上安装新版本的 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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