4

I am trying to update the python version in my already existing virtual environment. I installed python using following steps

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz tar xfz Python-2.7.11.tgz cd Python-2.7.11/ ./configure --prefix /usr/local/lib/python2.7.11 --enable-ipv6 make sudo make install 

I checked the version as well and its coming correctly

/usr/local/lib/python2.7.11/bin/python -V Python 2.7.11 

I have an existing virtualenv named test and I want to use python2.7.11 in this environment. It tried using

workon test --python /usr/local/lib/python2.7.11/bin/python 

But the version of python is shown as the old one only

python -V Python 2.7.6 

If I create a new environment, it works fine

mkvirtualenv test2 -p /usr/local/lib/python2.7.11/bin/python python -V Python 2.7.11 

I tried finding the solution but couldn't figure out how to modify python version in the existing virtual environment. Any help in figuring out the solution will be appreciated.

Thanks

0

1 Answer 1

2

The python interpreter in a virtualenv is definitive. But virtual envs are disposable, so I suggest you to create a new one with the good python interpreter.

Sign up to request clarification or add additional context in comments.

5 Comments

I have installed lot of stuff in this virtualenv and my website is running in this virtual env only. I don't want to setup everything again. Is there no way to update python?
You can easily rebuild it. In the old venv, pip freeze > /tmp/requirements.txt save all what you've installed in a single file. In the new virtualenv, pip install -r /tmp/requirements.txt reinstall everything.
Its not just installing things, I am running supervisor, celery, flower, django, elastic search etc. Apart from installing them, I will need to setup all the configurations again which I want to avoid.
Well your virtualenv folder should just be an execution context. In it you should find python/pip/... binaries and libraries. All your code and external parts should be somewhere else.
Agreed - a virtualenv directory should contain only python and things installed by pip. This is possibly a confusion when people say 'Run things in a virtualenv', and what 'in' means...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.