pip install virtualenv cd /path/to/project mkdir .venv virtualenv -p /usr/bin/python2.7 .venv source .venv/bin/activate ... #install packages, compile project, etc. ... deactivate
pip install virtualenv cd C:\path\to\project mkdir .venv virtualenv -p C:\\Python27\\python.exe .venv .venv\Scripts\activate.bat ... REM install packages, compile project, etc. ... REM close command prompt
One of Python's powers is how easy it is to create and use modules and packages to extend the built-in functionality. By default all packages are installed in a global repository and are available to all projects that may need them.
This is very convenient until you need to use different versions of
the same package in separate projects. That is why it is common
convention to use the
virtualenv tool when using python packages.
virtualenv is a tool for creating of isolated Python environments.
Such virtual environments contain all package dependencies of a project
and thus helps to avoid conflicts in package version requirements
across multiple Python projects.
virtualenv includes three steps:
pip install, edit sources, compile project.
deactivatescript or just close the terminal/console.
Deactivation cleans up the temporary environment variables and is is required only if you intend to use the same terminal/console to work on another project. Usually it is enough to just close the terminal/console window.