Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a VPS with system-wide installed python 2.5. I installed python 2.7 to one of the user's home dir (using --prefix). added it to bashrc and bash_profile, exported python variable to env, and now when I type python in console python 2.7 is running. But when I checked python version from my application (Django using with FastCGI) I still see that it is using 2.5. In ps output I see python processes running for this account and apache processes runing with hosting-specific account. How can I switch this particular account to 2.7 without changing system-wide version? Thanks!

share|improve this question

2 Answers 2

One option is to use the python virtualenv tool to create a Python virtual environment that you can source in your .bashrc.

mike@tester:~$ virtualenv --python=/usr/bin/python3 $HOME/fcgi_python
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in fcgi_python/bin/python3
Also creating executable in fcgi_python/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.

mike@tester:~$ python --version
Python 2.7.5+

mike@tester:~$ source $HOME/fcgi_python/bin/activate

(fcgi_python)mike@tester:~$ python --version
Python 3.3.2+

In the example above you would replace the argument after --python= with the path to the Python interpreter installed in the user's home directory.

share|improve this answer
up vote 0 down vote accepted

I had a call to python interpreter via env program in my fast cgi dispatch script. When I explicitly put path to 2.7 to the first line of the script it works as expected.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.