Install new python version on Debian Linux server

I ssh to a server running Debian Linux (version 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 is symbolically associated with / usr / bin / python ). I am very new to Linux. I want to install python 2.7.8 on a server without making it transparent to other server users. What is the best way to do this? My idea was to install in /usr/bin/python2.7 so that I can run my scripts as shown below:

$python2.7 myScript.py 

But I do not quite understand how such an installation will affect other users. Also, if I want to install packages (e.g. cv2), how should I do this for my python version

+1
source share
1 answer

I think you better install python 2.7.8 with compilation into your home directory. This is definitely clear to others. The "update-alternatives" command does the default python version change.

In my case, I created a hidden directory ".opt" in my account. Then download and extract the source code from python.org ( https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz ) using the command below.

 $ 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 

This will make the Python-2.7.8 directory in your account. Therefore, change the Python-2.7.8 directory.

 $ cd Python-2.7.8 

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

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

It will be configured with the setting in your home directory. After that, you can do and install.

 $ make && make install 

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

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

It will only work for your account.

+1
source

All Articles