How to fix pip under Debian 6.0 (squeeze): ImportError: cannot import name parser

Posted on Thu 02 May 2013 in HowTo, Linux, Programmazione, Python, Ubuntu (EN)

The pip utility distributed with Debian 6.0 has a bug once you upgrade it with pip install -U pip. You will easily get this error when you try to install a new package with it:

[email protected]:~# pip install setproctitle
Traceback (most recent call last):
File "/usr/bin/pip", line 8, in 
from pip.baseparser import parser
ImportError: cannot import name parser

Luckly there is a very easy workaround:

easy_install pip
rm /usr/bin/pip
ln -sv /usr/local/bin/pip-2.6 /usr/bin/pip
pip install pip --upgrade


Using virtualenv to manage multiple Python/Django environments in the same machine

Posted on Thu 25 April 2013 in HowTo, Linux, Programmazione, Python, Ubuntu (EN) • Tagged with Django, Python, virtualenv

Developing Python applications sometimes it's useful to be able to test the code with different environments, for example a particular version of Python or a specific Django version etc... Setting up many different virtual machines would be really too much work and even using a chroot environment is not what you need in some cases. Thanks to virtualenv is it possible to create a self contained Python environment with all the specific libraries you may need. Using virtualenv is very easy:

  • Creating the virtual environment: virtualenvmyenv¬†--no-site-packages
  • Entering the virtual environment: source myenv/bin/activate
  • Deactivating the virtual environment: deactivate

That's it! Once you're inside the virtual environment you will be using the Python libraries inside it. I suggest you to install all the Python libraries you need using pip.