Difficulties with PIP

As I have noted before, the foundation for my work in Python is built on first installing the Xcode Command Line tools, then install MacPorts, then installing (using MacPorts) Python and PIP. Everything I then install within my Python setup, which is pretty much everything else, is done using PIP, so when I kept getting the error below after finally acquiescing to macOS’s demands to upgrade to High Sierra, I was more than a little concerned:

ImportError: No module named 'packaging'

See below for the complete traceback.1

I tried install setuptools using MacPorts, as well as uninstalling PIP. I eventually even uninstalled both Python and PIP and restarted my machine. No joy.

Joy came with this SO thread which suggested I try:

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

Everything seems to be in working order now.

Traceback (most recent call last):
  File "/opt/local/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/john/Library/Python/3.4/lib/python/site-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'
~ % sudo pip search jupyter
Traceback (most recent call last):
  File "/opt/local/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/john/Library/Python/3.4/lib/python/site-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'
~ % sudo pip install setuptools
Traceback (most recent call last):
  File "/opt/local/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/john/Library/Python/3.4/lib/python/site-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'

  1. For those interested, the complete traceback looked like this: 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.