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

查看:326
本文介绍了在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 中,以便我可以使用如下运行我的脚本:

  $ python2.7 myScript.py 

但是我不完全清楚这样的安装会影响其他用户。另外,如果我想安装软件包(如cv2),我应该怎么做我的版本的python

解决方案

我认为您最好在主目录中编译python 2.7.8来安装。这对其他人来说肯定是明确的。 'update-alternatives'命令使系统默认的python版本更改。



在我的情况下,我在我的帐户中创建了隐藏的目录.opt。然后从python.org下载并提取源代码( https: //www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz ),具有以下命令。

  $ 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。

  $ cd Python-2.7.8 

请使用'前缀'选项进行配置。在我的情况下'--prefix = $ HOME / .opt'。

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

将在您的主目录中配置设置。之后,您可以制作和安装。

  $ make&& make install 

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

  $ echoexport PATH = $ HOME / .opt / bin:$ PATH>> $ HOME / .bashrc 

它只适用于您的帐户。


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

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

解决方案

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.

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

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

$ cd Python-2.7.8

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

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

It'll be works only for your account.

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

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