Python Development Environment — Part II


Let’s start with Part II of Python Development Enviroment set up. After you setting up the isolated environment with virtualenv, the next question is how to install Python package(s)? As we set our virtual environment to not use system-wide Python package, it is really troublesome to install it manually.

Met pip, a next generation of Python package manager. You can see in the website, that pip is built to improve easy_install. pip has a lot of advantages on easy_install, but it has some drawbacks too, such:

  1. cannot install from eggs. pip only install from source.
  2. does not understand setuptools extras
  3. not compatible to package which extensively customize distutils or setuptools in their setup.py file

pip is a perfect combination for virtualenv, they even state that pip is most nutritious when you used it with virtualenv. You can force pip to only run when a virtual environment activated by issuing this command:
export PIP_REQUIRE_VIRTUALENV=true
in your shell.

How to use pip? If you search for a Python package, just type
pip search
and install it by
pip install
pip will manage all the requirements by using information from PyPI

The most awesome feature of pip is the ability to “freeze” the requirements packages of a virtual environment. You can use this “requirement files” to install to another virtual environment. You can do it by typing these:
$ pip freeze > requirement.txt ## Generating requirement files
$ pip install -r requirement.txt ## Install from requirement file

You can also install bash completion with issuing this command
$ pip completion –bash >> ~/.profile

pip is a wonderful tool, use it with virtualenv and let the code begin.

About these ads
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: