Somehow my python on my Mac OS X is messed up.

I am trying to install virtualenv

$ pip install virtualenv

And it gives me:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.40-py2.7.egg/pkg_resources.py", line 16, in <module>
    import sys, os, zipimport, time, re, imp, types
ImportError: No module named time

However if I try it like this, it finds time.

$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time

My path variable looks like this:

$ echo $PATH

Could it be that my path variable is set wrong? Where and how can I fix this?

  • You could look into the Anaconda distribution of Python from Continuum IO if you want. It's a pretty decent distro packed with a bunch of libraries, and it just works. No need to personally manage libraries anymore. Commented Jul 14, 2013 at 2:22

1 Answer 1


You are using multiple versions of Python simultaneously - one from Python.org (2.7.3), located in /Library/Frameworks/Python.framework/Versions/2.7/, which does not have an installation of pip associated with it, and another version from HomeBrew (2.7.5), located in /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/. Your pip script is using the /usr/local/... Python, which doesn't have the time module available for some reason, but when you just type python on the command line, the shell searches through your $PATH and runs the version in /Library/Frameworks/.... If you were to type /usr/local/bin/python on the command line and enter import time you will likely get an error. The time module is part of the Python standard library, so I'm not sure why homebrew isn't finding it - you might want to re-brew python to fix it.

To always run the homebrew version of python (if that's what you want your primary version to be), just put /usr/local/bin as the first entry in your $PATH variable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .