Python ImportError: no module named os

18,202

The issue was changing PYTHONHOME, which could not find any modules because I have python running out of a user directory /Users/alavin89/Library/Python/2.7/lib/python/site-packages. Check the python path by running echo $PYTHONPATH. The fix:

unset PYTHONHOME
sudo pip uninstall matplotlib
pip uninstall matplotlib
pip install --user matplotlib

Note: running uninstall again w/o sudo is to double-check it worked properly.

Share:
18,202
BoltzmannBrain
Author by

BoltzmannBrain

Updated on June 04, 2022

Comments

  • BoltzmannBrain
    BoltzmannBrain almost 2 years

    Trying to upgrade matplotlib as in this post, I ran

    export PYTHONHOME=/usr/lib/python2.7/
    sudo easy_install -U distribute
    sudo pip install --upgrade matplotlib
    

    Now whenever I try to run python I get ImportError: no module named os. What happened? Please help me. I'm on OS X 10.9.5.