15

When I tried installing Flask I got this error:

ImportError: No module named packaging.version
SparkAndShine
  • 15,667
  • 17
  • 84
  • 129
Prashanth
  • 1,153
  • 2
  • 12
  • 26

4 Answers4

15

To fix this, I had to do:

pip install setuptools
Prashanth
  • 1,153
  • 2
  • 12
  • 26
13

If your Python runs on Ubuntu, try to do this:

cd /usr/local/lib/python2.7/dist-packages
mv pkg_resources/ pkg_resources_bak/

I'm not sure what package installed the "pkg_resources", it will make pip always show error.

Pang
  • 9,073
  • 146
  • 84
  • 117
José T. Lin
  • 149
  • 6
7

Try this

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
algometrix
  • 3,294
  • 2
  • 13
  • 22
  • 1
    I was having the above-mentioned error on my raspberry pi model B. If anyone else comes here with my problem, this answer fixed it for me. – Arjun Mar 09 '17 at 02:46
  • I encountered this error on macOS after upgrading to High Sierra and re-installing MacPorts. Nothing worked until I tried this. – John Laudun Feb 23 '18 at 00:27
3

As an Ubuntu 14.04 user, upgrading pip to version 9.0.1 fixed this problem for me.

Upgrading pip normally

  • Download get-pip.py script
  • Run: python get-pip.py

Upgrading/installing pip behind a corporate firewall

  • Download get-pip.py script, along with pip, wheel, and setuptools from pypi
  • Place all files in the /tmp directory
  • Run the following command to install pip: sudo -H python /tmp/get-pip.py --no-index --find-links=/tmp pip
Jordan
  • 231
  • 3
  • 9