"No module named time"

fisherman picture fisherman · Nov 18, 2013 · Viewed 20.3k times · Source

I compiled Python from source using:

wget http://python.org/ftp/python/2.6.6/Python-2.6.6.tar.bz2 
tar jxvf Python-2.6.6.tar.bz2 
cd Python-2.6.6 
./configure 
make            
make install 

Version of Python:

as3:~# python -V
Python 2.6.6

I also installed pip installer but when I use pip install xxx, I always get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.6/site-packages/distribute-0.6.49-py2.6.egg/pkg_resources.py", line 16, in <module>
    import sys, os, time, re, imp, types, zipfile, zipimport
ImportError: No module named time

How do I fix this?

Answer

Aaron Digulla picture Aaron Digulla · Nov 18, 2013

You need to save all the output generated by configure in a file and check whether it tried to build the time module and if not, then why not.

Usually, this doesn't happen because of missing header files. Fix these problems and build Python again.

If you have a package manager, then you should really consider installing Python from there: It will then come with all the dependencies and all available modules should just work.

Lastly, make sure you execute the correct executable. To check this, run Python with an absolute path. To execute it in the current folder, use $PWD/python.