How to solve import error for pandas?

95,197

Solution 1

Pandas has portions of its code written in C to make it run faster. If you tried to install pandas manually you would need to build it. Try reinstalling it with miniconda package manager here: http://conda.pydata.org/miniconda.html

and then you can just do

conda install pandas

There are very simple instructions on how to do it in the link below. Just do ctrl-f miniconda to find the section that talks about it

http://pandas.pydata.org/pandas-docs/dev/install.html

Solution 2

I was having the same problem now with Python 3.4.3.

I was using pandas-0.18.0.

Upgrading (using pip) solved the issue for me:

[sudo] pip install --upgrade pandas

The final result of the upgrade:

Successfully installed numpy-1.13.3 pandas-0.21.0 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0

After this, the issue was gone!

Solution 3

I had the same problem and the issue came from an encoding problem. My os was previously set up in French and everything was fine. But then when I switched to English I had the error above.

You can type

locale

in the terminal to check the local environment variables.

When set up in French, I had this configuration: French config. Then, after I switched to English, I had: English config.

I then added the following lines in the .bash_profile under /Users/myName and everything went back to normal.

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Solution 4

I was having this problem with python 2.7.13 here is my solution: 1. install Cython with

pip install Cython

2. install g++ and gcc

apt-get install gcc, g++

3. uninstall pandas

pip uninstall pandas

4. reinstall pandas

pip install pandas

then everything will be OK.

Solution 5

I was unable to upgrade pandas with regular

pip install --upgrade pandas 

"tensorflow 1.6.0 has requirement numpy>=1.13.3, but you'll have numpy 1.13.1 which is incompatible."

However bumping it with:

pip install --upgrade pandas --force

solved issue completely

Share:
95,197
Alex F
Author by

Alex F

Updated on October 15, 2021

Comments

  • Alex F
    Alex F over 2 years

    I installed Anaconda with python 2.7.7.
    However, whenever I run "import pandas" I get the error:
    "ImportError: C extension: y not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first."
    I tried running the suggested command but it stated that

    skipping 'pandas\index.c' Cython extension (up-to-date)      
    skipping 'pandas\src\period.c' Cython extension (up-to-date) 
    skipping 'pandas\algos.c' Cython extension (up-to-date)      
    skipping 'pandas\lib.c' Cython extension (up-to-date)        
    skipping 'pandas\tslib.c' Cython extension (up-to-date)      
    skipping 'pandas\parser.c' Cython extension (up-to-date)     
    skipping 'pandas\hashtable.c' Cython extension (up-to-date)  
    skipping 'pandas\src\sparse.c' Cython extension (up-to-date) 
    skipping 'pandas\src\testing.c' Cython extension (up-to-date)
    skipping 'pandas\msgpack.cpp' Cython extension (up-to-date)
    

    Has anyone encountered this before and found a solution?