virtualenv
Installation
_$: apt-get install python-pip python-virtualenv virtualenvwrapper
Virtual environment creation
_$: virtualenv venv
Virtual environment creation with Python 3
There are several ways to create virtual environments with Python 3. Since this article started with Python 2.7 in the operating system and Python 3.4 in the virtual environment and is (as of now) with Python 3.5 in both operating system and virtual environment, you will find a big list. The newest and therefore recommended way is the last one.
a) Use the python3 binary already available in your system:
OS: Python 2.7. Python 3 installed as a separate binary.
_$: which python3
/usr/bin/python3
_$: virtualenv -p $(which python3) venv
b) Use the pyvenv
program:
OS: Python 3.3 or Python 3.4
_$: pyvenv-3.4 venv34-pyvenv --without-pip
_$: source ./venv34-pyvenv/bin/activate
_$: wget https://pypi.python.org/packages/source/s/setuptools/setuptools-9.1.tar.gz
_$: tar -vzxf setuptools-9.1.tar.gz
_$: cd setuptools-9.1
_$: python setup.py install
_$: cd ..
_$: wget https://pypi.python.org/packages/source/p/pip/pip-6.0.tar.gz
_$: tar -vzxf pip-6.0.tar.gz
_$: cd pip-6.0
_$: python setup.py install
_$: cd ..
_$: deactivate
_$: source ./venv34-pyvenv/bin/activate
c) Use the virtualenv-3.4
program:
OS: Python = 3.4 (alternative method)
_$: sudo easy_install --upgrade pip
_$: pip install --upgrade virtualenv
And you are ready to create virtual environments:
_$: virtualenv-3.4 venv
d) Use the venv
module:
OS: Python >= 3.5
_$: sudo apt install python3.5-venv
_$: python3.5 -m venv ./venv