I've been hearing the buzz about virtualenv lately, and I'm interested. But all I've heard is a smattering of praise, and don't have a clear understanding of what it is or how to use it.
I'm looking for (ideally) a follow-along tutorial that can take me from Windows or Linux with no Python on it, and explain every step of (in no particular order):
virtualenv
virtualenv
is a good ideavirtualenv
virtualenv
And step through (comprehensively) a couple sample situations of the should+can variety.
So what are some good tutorials to cover this stuff? Or if you have the time and interest, perhaps you can answer a few of those questions here. Either in your answer, or as a link to tutorials that answer it, these are the things I'd like to know.
You can deactivate a virtual environment by typing “deactivate” in your shell. The exact mechanism is platform-specific and is an internal implementation detail (typically a script or shell function will be used).
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
In fact, virtualenv comes with a copy of pip which gets copied into every new environment you create, so virtualenv is really all you need. You can even install it as a separate standalone package (rather than from PyPI).
Check the $VIRTUAL_ENV environment variable. The $VIRTUAL_ENV environment variable contains the virtual environment's directory when in an active virtual environment. Once you run deactivate / leave the virtual environment, the $VIRTUAL_ENV variable will be cleared/empty.
This is very good: http://simononsoftware.com/virtualenv-tutorial-part-2/
And this is a slightly more practical one: https://web.archive.org/web/20160404222648/https://iamzed.com/2009/05/07/a-primer-on-virtualenv/
Virtualenv is a tool to create isolated Python environments.
Let's say you're working in 2 different projects, A and B. Project A is a web project and the team is using the following packages:
The project B is also a web project but your team is using:
The machine that you're working doesn't have any version of django, what should you do? Install django 1.4? django 1.6? If you install django 1.4 globally would be easy to point to django 1.6 to work in project A?
Virtualenv is your solution! You can create 2 different virtualenv's, one for project A and another for project B. Now, when you need to work in project A, just activate the virtualenv for project A, and vice-versa.
A better tip when using virtualenv is to install virtualenvwrapper to manage all the virtualenv's that you have, easily. It's a wrapper for creating, working, removing virtualenv's.
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