Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pylab ImportError: No module named _thread

From ubuntu 10.04, I installed pylab with easy_install. After some upgrade, 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's features.
%quickref -> Quick reference.
help      -> Python's 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 failes as follow:

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 issue. I remove the old version (1.4.3) installed with synaptic but that doesn't fix the problem.

How could I fix it without reinstalling everything? Thank you. Jean-Patrick

like image 588
Jean-Pat Avatar asked Dec 05 '11 09:12

Jean-Pat


1 Answers

It is caused by dateutil.

As you can see, you have installed dateutil 2.0 using easy_install, but it's not compatible with python 2.x. You should uninstall (or just delete the whole folder) the 2.0 version and then go to its homepage and download version 1.5, then manually install it.

Version 2.0 is for Python 3.x, which you can find on the homepage too.

--UPDATE--

dateutil 2.1 is out and now it is NOT needed to use 1.5 anymore, if you can stand six get installed too :)

like image 97
Felix Yan Avatar answered Oct 19 '22 19:10

Felix Yan