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:
- cannot install from
eggs.piponly install from source. - does not understand
setuptoolsextras - not compatible to package which extensively customize
distutilsorsetuptoolsin theirsetup.pyfile
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.
“
No trackbacks yet.