Mac OSX 10.6.8 (Snow Leopard):
The system python is in
/usr/bin, while the various python versions I installed were, by default, installed into:/usr/local/binThe various pythons I installed have names like
python2.7orpython3.2, and I can use those names rather than full paths.When you do
pip install virtualenv, the pip command is associated with one of your python versions, andvirtualenvgets installed into that version of python (you can do$ which pipto see what version of python that is). By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python that you want for a new environment using the -p flag:virtualenv -p python3.2 my_env
Running virtualenv with interpreter /usr/local/bin/python3.2
New python executable in my_env/bin/python
Installing setuptools, pip...done.
virtualenv my_env will create a folder in the current directory which will contain the Python executable files, and a copy of the pip [command] which you can use to install other packages.
http://docs.python-guide.org/en/latest/dev/virtualenvs/
Installing virtualenvwrapper:
- I had some problems installing virtualenv wrapper. This is what I ended up putting in
~/.bash_profile:
....
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/django_projects #Not very important -- mkproject command uses this #Added the following based on: #http://stackoverflow.com/questions/19665327/virtualenvwrapper-installation-snow-leopard-python export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7 #source /usr/local/bin/virtualenvwrapper.sh source /Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh - The -p flag works differently with virtualenvwrapper: I have to specify the full path to the python interpreter that I want to use(if it's not the default):
...
$ mkvirtualenv -p /usr/local/bin/python3.2 my_env Running virtualenv with interpreter /usr/local/bin/python3 New python executable in my_env/bin/python Installing setuptools, pip...done. Usage: source deactivate removes the 'bin' directory of the environment activated with 'source activate' from PATH. Unlike virtualenv, virtualenvwrapper will create the env at the location specified by the $WORKON_HOME environment variable. That keeps all your environments in one place.