Jason Prawn
Jason Prawn

Reputation: 1053

Python configparser error after Yosemite install

I've upgraded to Yosemite and this seems to have broken my python modules.

python --version == Python 2.7.6

Then from the Python shell:

>>> import pyrax
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pyrax/__init__.py", line 38, in <module>
    import six.moves.configparser as ConfigParser
ImportError: No module named configparser

So its complaining about configparser.

pip show configparser
---
Name: configparser
Version: 3.3.0r2
Location: /Library/Python/2.7/site-packages
Requires: 

But it is there. After some reading it seems clear that ConfigParser has been renamed to configparser in python version 3. I am however running 2.7.

--- EDIT ----

Some more info:
I'm not using homebrew for Python
I've tried re-installing pyrax

Any ideas ?

Upvotes: 5

Views: 3605

Answers (2)

Byron McCollum
Byron McCollum

Reputation: 91

Just move the old six out of the way, and reinstall via pip...

mkdir ~/six-old-library/
mkdir ~/six-old-system-library/
sudo mv /Library/Python/2.7/site-packages/six* ~/six-old-library/
sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six* ~/six-old-system-library/
sudo pip install six

Upvotes: 9

Patricio del Sol
Patricio del Sol

Reputation: 21

I had the same problem and spent a couple of hours investigating it.
I learned that the default python for OS X 10.10 contains an outdated six package.

This is how I fixed it:

  1. Install the python package from homebrew:

    brew install python
    

    Make sure that homebrew python is your default system version. Check brew doctor and your default $PATH:

    brew doctor
    

    Should say "Your system is ready to brew." If it doesn't, you need to fix it first. We need to use homebrew's python, not OS X's python:

    which python
    

    Should output and point to "/usr/local/bin/python"

    If it doesn't, check your $PATH - it should output "/usr/local/bin" first, then "/usr/bin". If it doesn't, update it in .bash_profile and/or .zshrc.

  2. Uninstall all your python packages:

    pip freeze | grep -v "^-e" | xargs pip uninstall -y
    
  3. Reinstall all your python packages as needed:

    pip install -r requirements.txt
    

After all that, it should work.

Upvotes: 2

Related Questions