

With virtualenv installed, you can just cd to your project directory, and then make a new environment: virtualenv (hint for OS X users that got here, try sudo easy_install pip, you might have to use the command as pip2 instead of pip, just check for the –version)

Pip’s the most reliable way to manage packages, and like the link above says, it’s the recommended way to do it also. If you get an error here, saying that you need to install pip first, go ahead and do so. In Python 2 you’ll want to install virtualenv using pip: pip install virtualenv The first thing to do is set up a virtual environment. It’s a good idea to keep track of these in a text file that can be used by pip to install them later.

Any of the packages you get from the package index, for example, will need to be installed on your production machine as well. You have to remember that for any version of Python, you are going to need to deploy that same setup to your production environment. Setting up a proper environment for working is going to be important, and can be confusing at first, because you might think you are ready to write with it simply installed on your machine. One of the great things about Python is that it is fantastically simple to get working this simplicity is also one of the pitfalls. If you are missing one or the other, or if you find you are running an older version, just install the newest: sudo apt-get install python *or* python# Environments matter Just remember which one your machine defaults to, and which one you are wanting to target. There’s a whole different article to be written about changing your default Python install, so I’m going to avoid that discussion here. This will be important because it will determine how we run our Python code from whatever interpreter we end up using.
