dimanche 25 mai 2014

Django - créer un environnement virtuel pour python 2.7 - Stack Overflow


I want to install django, but my system which it's os is mac has python 2.6 which can't support django. so I installed python 2.7 but at that time when I typed python in terminal it response the version is 2.6 after searching I change it to python 2.7 where both of them are still on my computer, when I want to install django it still install it for 2.6 so I decide to install virtual environment but when I create a new environment using "virtualenv venv" it produce environment with python version 2.6! I really confused what should I do to create virtual environment with python 2.7?




The short answer is that you can edit the PATH in ~/.bash_profile to make sure that path for python 2.7 is in front of 2.6 version.


It is a good/common practice to not touch the system python on MAC OS and install a latest version using homebrew. After you installed brew you can install python by:


brew install python

Homebrew will take care of the PATH. After that you will be able to install packages and control virtual environments with your 2.7 installation.




You can specify your python interpreter as a prefix to virtualenv_install


Refer to this post: It is possible to install another version of Python to Virtualenv?


What I mean to say is create a new virtual env with the correct python interpreter by specifying it as such:


mkdir virtualenvs
cd virtualenvs
~/.localpython/bin/virtualenv py2.7 --python=/home/<user>/.localpython/bin/python2.7

(See the stackoverflow post I mentioned)



I want to install django, but my system which it's os is mac has python 2.6 which can't support django. so I installed python 2.7 but at that time when I typed python in terminal it response the version is 2.6 after searching I change it to python 2.7 where both of them are still on my computer, when I want to install django it still install it for 2.6 so I decide to install virtual environment but when I create a new environment using "virtualenv venv" it produce environment with python version 2.6! I really confused what should I do to create virtual environment with python 2.7?



The short answer is that you can edit the PATH in ~/.bash_profile to make sure that path for python 2.7 is in front of 2.6 version.


It is a good/common practice to not touch the system python on MAC OS and install a latest version using homebrew. After you installed brew you can install python by:


brew install python

Homebrew will take care of the PATH. After that you will be able to install packages and control virtual environments with your 2.7 installation.



You can specify your python interpreter as a prefix to virtualenv_install


Refer to this post: It is possible to install another version of Python to Virtualenv?


What I mean to say is create a new virtual env with the correct python interpreter by specifying it as such:


mkdir virtualenvs
cd virtualenvs
~/.localpython/bin/virtualenv py2.7 --python=/home/<user>/.localpython/bin/python2.7

(See the stackoverflow post I mentioned)


0 commentaires:

Enregistrer un commentaire