Last Updated: February 25, 2016
·
589
· orangetux

Alias to fix your virtualenv

Every now and then setuptools brakes my virtualenv for some reason with an error like this:

Traceback (most recent call last):
  File "/var/www/mydir/virtualenvs/dev/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

You can fix this easily by reinstalling setuptools, but I always have lookup the one liner to fix it. Add this to your .zshrc, .bashrc or .whatevershellyouuserc:

alias fix_python="curl https://bootstrap.pypa.io/ez_setup.py | python && rm setuptools-[0-9].[0-9].zip"

reload your config and run fix_python to fix your virtualenv.