简体   繁体   中英

How install and use another version python(python 2.7) on linux with the default python version is python 2.6

There is a default python version, namely python 2.6, on the GPU server with Linux OS. Now I want to install a new python version on the server from its source, namely python 2.7. I should not change the default python version since I am not the administrator and some reason. So what should I do?

You can install your new version of Python. It should be accessible with the python27 command (which may be a symbolic link). Then you will just have to check that the python symbolic link still points to python26 .

Doing this, python will keep on execute Python 2.6 while python27 will execute Python 2.7

You can use virtualenv , to execute your programm in an environment with python 2.7.

Install virtualenv and virtualenvwrapper (for comfotable use.)

mkvirtualenv -p <your-python-version> would then start a virtual environment where the desired python version is the default.

To build on Tryph's answer, you can install that new version to your home directory, then in a directory specified within your PATH (like in .bash_profile), you can point to that directory and within there create a sym-link that points to the new python.

For instance, if you have a bin folder in your home directory that is specified in the path

ln -s /bin/python ~/bin/python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM