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.