1

I ran into the following error while using pip: "pip stops with ImportError for request-Modul"

I read on a forum that an easy solution was to just apt-get remove pip and then to do easy_install pip. I did this, and it did indeed make pip start working again.

However, I later read that using easy_install is a bad idea and can break apt's package management. So my question is, how do I "undo" whatever easy_install did and get apt to manage pip properly again?

2

What you have to do:
Reinstall the python-pip package with apt and afterwards upgrade your pip to the latest version with pip itself or easy_install if it is broken.

sudo apt-get install python-pip
sudo pip install --upgrade pip || sudo easy_install --upgrade pip

Why you should do that:
apt only installs packages it finds in your installed repositories, but the python packages in the official repositories are incredibly outdated! However, some packages you might install in the future may list python-pip as dependency and and require that package to be installed. They won't recognize it if you installed it without apt. Also, the man command does not work for pip then as only apt creates a manpage for it, easy_install does not.

easy_install and pip however don't fetch their packages from any repository, but from PyPI (Python Package Index), which always holds the latest available versions.

So my suggestion is to use pip instead of apt to update python packages if you want current versions. easy_install is the ancestor of pip and should usually be avoided and replaced by pip, but as long as it's broken, you have to use it. You could also do a sudo pip install --upgrade pip to get the latest pip version without easy_install.

If you don't have the pip package installed by apt, then just do it additionally. I did not remove python-pip with apt before upgrading it with pip or easy_install and it also works. As apt installs the old pip version in /usr/bin and pip/easy_install use the directory /usr/local/bin, which has the higher priority, a plain call to pip without giving an explicit directory always runs the newer version, if more than one is installed.

  • Thank you for your detailed answer! Just to be clear though, you say that after I apt-get install python-pip, that I should use pip to update itself from then on. Will apt conflict with this later when I do apt-get upgrade, or should it be fine since the pip install --upgrade pip version will be later than the apt version? – J. Taylor Aug 31 '15 at 21:06
  • 1
    The old repository (apt) pip is installed in /usr/bin/ and the new pip/easy_install pip is located in /usr/local/bin, which is the path with higher priority and therefore, the new pip gets executed when you just type pip without an explicit directory. So both pip versions exist in parallel without disturbing each other. - I edited my answer to include this and correct my previous inaccuracy. – Byte Commander Sep 1 '15 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.