Switch between Python versions as non root

前端 未结 3 1210
后悔当初
后悔当初 2021-01-06 12:38

I just installed Python 2.7 in our server, they had 2.4 installed before hand.

After I built the new version, my path is still pointing to the old version of python,

3条回答
  •  轮回少年
    2021-01-06 13:12

    Because you are on the server and don't have root permissions, the best choice for you is to use virtualenv

    Build Python 2.7, for example, as following:

    $ ./configure --prefix=~/mydir
    $ make
    $ make install
    

    Download virtualen.py file and run:

    $ ~/mydir/bin/python virtualenv.py my_environment
    

    This will create an isolated Python 2.7 environment for you inside my_environment directory.

    To activate it run source my_environment/bin/activate and that's it. Now python executable will be your Python 2.7. Additionally you will have pip installed and thus can easily install any additional libraries into your environment.

提交回复
热议问题