Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/", 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?

share|improve this question
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. – Ambidextrous Jul 14 '13 at 2:22
up vote 2 down vote accepted

You are using multiple versions of Python simultaneously - one from (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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.