Importing pandas shows ImportError: cannot import name hashtable

后端 未结 5 1897
北恋
北恋 2020-11-29 07:16

I have installed pandas on python 3.3, and coded like this:

import csv
import pandas
from pandas import DataFrame

csvdata = pandas.read_csv(\'datafile.csv\'         


        
相关标签:
5条回答
  • 2020-11-29 07:52

    I had the same problem too when I tried installing pandas 0.13.1. It installed but I could not import it.

    As @danioyuan suggests, I installed Cython using easy_install and now I am able to import pandas.

    0 讨论(0)
  • 2020-11-29 08:01

    I encountered the same problem. I installed pandas using command pip install pandas.

    By default, my pip installed pandas in dist-packages of python3.2 and my default python version was 2.7. As a result when I did python to open the interactive shell and try to do

     import pandas
    
     File "<stdin>", line 1, in <module>
     File "/usr/local/lib/python3.2/dist-packages/pandas/__init__.py", line 6, in <module>
     from . import hashtable, tslib, lib
     ImportError: cannot import name hashtable
    

    What solved my problem was:

     python3.2
     import pandas
    

    Please check that the you use the same Python version whose dist-packages contain pandas.

    0 讨论(0)
  • 2020-11-29 08:07

    The pandas Python 3.3 binary here http://www.lfd.uci.edu/~gohlke/pythonlibs/ seems to have not been compiled successfully. I haven't had the time to configure my build machine to build and test Python 3.3 binaries but I do know that things work on Python 3.3 on the other platforms.

    0 讨论(0)
  • 2020-11-29 08:13

    I have already tried all the stuff above, didn't work for me.

    You can just change your version of pandas by

    pip install --user pandas==0.22
    

    only this worked for me:)

    0 讨论(0)
  • 2020-11-29 08:17

    Update: I now recommend installing the scientific python stack using Anaconda.

    Pandas comes bundled and can easily be updated using conda:

    conda update pandas
    

    It also comes bundled with cython, scipy (which is tricky to install via pip), statsmodels, and manages the dependencies/reationships between these packages for you.

    It's worth emphaising that you don't need admin/sudo access to install it on the machine to install Anaconda.


    If you're not using Anaconda, the recommended way to install pandas is via pip (on Mac and Windows):

    pip install pandas
    

    On Linux you can also install with python-pandas in whichever repository, but be aware you may be installing an older version of pandas, ideally you should be using the latest stable version.


    It looks like you have tried to install from source, about which the docs mention:

    Installing from the git repository requires a recent installation of Cython as the cythonized C sources are no longer checked into source control. Released source distributions will contain the built C files. I recommend installing the latest Cython via easy_install -U Cython

    Note that you will not be able to import pandas if you open an interpreter in the source directory unless you build the C extensions in place:

    python setup.py build_ext --inplace
    

    Without compiling hashtables.pyx (and a few other cython files), pandas is unable to import them. These are required for pandas (which explains your error message).

    Note: this error message has been made more descriptive for 0.11.1 onwards, it will say that the C-extensions were not built.

    0 讨论(0)
提交回复
热议问题