brew pip: "ImportError: No module named packaging.version"

akprasad at gmail.com akprasad at gmail.com
Mon Jul 17 16:22:17 EDT 2017


Hiya. I'm running El Capitan and have a Homebrew install of python (as well as one in /usr/bin/python, which I can't recall how I installed). I had some trouble pip installing Keras:

$ sudo pip install keras
…
    DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.

The recommended solution is to make sure I'm using brew python:

$ brew link --overwrite python.
Linking /usr/local/Cellar/python/2.7.13... 39 symlinks created

But now pip (/usr/local/Cellar/python/2.7.13/bin/pip) does not work:

$ pip -V
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/aditpras/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named packaging.version

(Not only that, but the usual instructions for reinstalling pip, such as "proxy python -m pip install -U pip" and "python get-pip.py" tell me "Requirement already up-to-date" without fixing anything.)

I eventually realized that easy_install'ing pip gives me a working pip again. The one in Cellar still does not work. To install Keras, I apparently have to do:

$ sudo pip install keras --ignore-installed numpy

Any tips? (I realize I can just use pyenv or virtualenv).



More information about the Python-list mailing list