Pylab ImportError: no module named _thread

From ubuntu 10.04, I installed pylab with easy_install. After some update, I can import pylab. First, I run ipython installed from easy_install:

$ ipython Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) Type "copyright", "credits" or "license" for more information. IPython 0.11 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython features. %quickref -> Quick reference. help -> Python own help system. object? -> Details about 'object', use 'object??' for extra details. 

Then I try to import matplotlib

 In [1]: import matplotlib In [2]: matplotlib.__version__ Out[2]: '1.0.1' 

But when importing pylab, the following happens:

 In [3]: import matplotlib.pylab --------------------------------------------------------------------------- ImportError Traceback (most recent call last) /home/claire/<ipython-input-3-1d30b9aee20b> in <module>() ----> 1 import matplotlib.pylab /usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-i686.egg/matplotlib /pylab.py in <module>() 218 silent_list, iterable, dedent 219 --> 220 from matplotlib import mpl # pulls in most modules 221 222 from matplotlib.dates import date2num, num2date,\ /usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-i686.egg/matplotlib /mpl.py in <module>() 1 from matplotlib import artist 2 from matplotlib import axis ----> 3 from matplotlib import axes 4 from matplotlib import cbook 5 from matplotlib import collections /usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-i686.egg/matplotlib /axes.py in <module>() 17 import matplotlib.colors as mcolors 18 import matplotlib.contour as mcontour ---> 19 import matplotlib.dates as mdates 20 from matplotlib import docstring 21 import matplotlib.font_manager as font_manager /usr/local/lib/python2.6/dist-packages/matplotlib-1.0.1-py2.6-linux-i686.egg/matplotlib/dates.py in <module>() 117 import matplotlib.ticker as ticker 118 --> 119 from dateutil.rrule import rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, \ 120 MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY 121 from dateutil.relativedelta import relativedelta /usr/local/lib/python2.6/dist-packages/python_dateutil-2.0-py2.6.egg/dateutil/rrule.py in <module>() 11 import datetime 12 import calendar ---> 13 import _thread 14 import sys 15 ImportError: No module named _thread 

This may be a python_dateutil problem. I uninstall the old version (1.4.3) installed using synaptic, but this does not fix the problem.

How can I fix this without reinstalling everything? Thanks. Jean Patrick

+7
source share
2 answers

This is caused by dateutil.

As you can see, you installed dateutil 2.0 using easy_install but are not compatible with python 2.x. You must delete (or simply delete the entire folder) version 2.0 , and then go to its home page and download version 1.5 , then manually install it.

Version 2.0 is for Python 3.x, which you can also find on the home page.

- UPDATE -

dateutil 2.1 is missing and now it is NOT to use 1.5 , if you can stand six install too :)

+9
source

I got this fix simply:

 pip install python-dateutil 

I am running Python 2.7.3 (on OS X from Homebrew), and the installed datutil seemed to be a 2.x series (i.e. it should not be compatible with this Python). But it works.

Here is the complete set of commands for getting matplotlib et.al. runs on OS X Mountain Lion:

 brew install python brew link --overwrite python brew tap samueljohn/python brew install scipy pip install python-dateutil 

To check:

Take a .py source from here .

 python file.py 

Should open a GUI window with curves in it.

+3
source

All Articles