Virtualenv is only installed on DreamHost servers for Python 2. If you're working with Python 3, you must install virtualenv using pip3. pip3 is not installed on the server by default. You must first install a custom version of Python 3.
virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.
If you already have python3 installed as well virtualenvwrapper the only thing you would need to do to use python3 with the virtual environment is creating an environment using:
which python3 #Output: /usr/bin/python3
mkvirtualenv --python=/usr/bin/python3 nameOfEnvironment
Or, (at least on OSX using brew):
mkvirtualenv --python=`which python3` nameOfEnvironment
Start using the environment and you'll see that as soon as you type python you'll start using python3
You can make virtualenvwrapper use a custom Python binary instead of the one virtualenvwrapper is run with. To do that you need to use VIRTUALENV_PYTHON variable which is utilized by virtualenv:
$ export VIRTUALENV_PYTHON=/usr/bin/python3
$ mkvirtualenv -a myproject myenv
Running virtualenv with interpreter /usr/bin/python3
New python executable in myenv/bin/python3
Also creating executable in myenv/bin/python
(myenv)$ python
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
The latest version of virtualenvwrapper is tested under Python3.2. Chances are good it will work with Python3.3 too.
virtualenvwrapper now lets you specify the python executable without the path.
So (on OSX at least)mkvirtualenv --python=python3 nameOfEnvironment
will suffice.
On Ubuntu; using mkvirtualenv -p python3 env_name
loads the virtualenv with python3.
Inside the env, use python --version
to verify.
You can add this to your .bash_profile or similar:
alias mkvirtualenv3='mkvirtualenv --python=`which python3`'
Then use mkvirtualenv3
instead of mkvirtualenv
when you want to create a python 3 environment.
I find that running
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
and
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv-3.4
in the command line on Ubuntu forces mkvirtualenv to use python3 and virtualenv-3.4. One still has to do
mkvirtualenv --python=/usr/bin/python3 nameOfEnvironment
to create the environment. This is assuming that you have python3 in /usr/bin/python3 and virtualenv-3.4 in /usr/local/bin/virtualenv-3.4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With