Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed the Pandas module for Python 2.7 using apt-get. However, when I try to import the module, it raises an ImportError:

 import pandas as pd
 File "/usr/lib/pymodules/python2.7/pandas/__init__.py", line 15, in <module>
    raise ImportError('ImportError: C extensions not built: if you installed already verify that you are not importing from the source directory')

The call in /usr/lib/pymodules/python2.7/pandas/__init__.py is:

import pandas.lib as lib
except Exception:  # pragma: no cover
    import sys
    e = sys.exc_info()[1] # Py25 and Py3 current exception syntax conflict
    if 'No module named' in str(e):
        raise ImportError('C extensions not built: if you installed already '
                          'verify that you are not importing from the source '
                          'directory')
    else:
        raise

Why do I get ImportError and how do I solve this?

Following is what I get when trying to import the dependencies of Pandas in an interactive Python shell:

>>> import numpy as np
>>> import dateutil
>>> import pytz
>>> import numexpr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numexpr
>>> import bottleneck
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named bottleneck
share|improve this question
add comment

1 Answer 1

Following are the dependencies for Pandas:

  • NumPy
  • python-dateutil
  • pytz

And the Pandas project list the following two as highly recommended dependencies:

  • numexpr
  • bottleneck

It looks like apt-get only installed the required dependencies and not the highly recommended ones; as such you get an ImportError when trying to import numexpr and bottleneck. Installing these modules should most probably solve the problem.

Since, you are running Python 2.7 as evident from Python Traceback, install these two modules as suggested below:

  • numexpr is present in Ubuntu's repositories. So, install it by running:

    sudo apt-get install python-numexpr
    
  • bottleneck is not present in Ubuntu's repositories. So, install it using pip. We would also need to install build-essentials package in order to build bottleneck:

    sudo apt-get install python-pip build-essentials
    sudo pip install bottleneck
    
share|improve this answer
    
Thanx Aditya, You're right. It works –  user268000 Apr 14 at 0:22
    
It looks like apt-get only installed the required dependencies and not the highly recommended ones. –  user268000 Apr 14 at 0:23
add comment

Your Answer

 
discard

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.