How to solve import error for pandas?

后端 未结 11 1763
忘掉有多难
忘掉有多难 2020-11-29 08:03

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 impo

11条回答
  •  一个人的身影
    2020-11-29 08:50

    I tried all the solutions above, but nothing works out...

    Error Message

    I got an error message with ipython

    ImportError: C extension: iNaT not built. If you want to import pandas 
    from the source directory, 
    you may need to run 'python setup.py build_ext --inplace --force' 
    to build the C extensions first.
    

    and it suggests

    $ python setup.py build_ext --inplace --force
    

    Solution

    My suggestion: Be careful about the version issue!

    I clone pandas from the official github repo, then build it myself and install by pip

    Following is the command I typed in terminal

    $ cd pandas
    
    $ python setup.py build_ext --inplace --force
    
    $ sudo pip install .  # don't forget the dot 
    

    or, if you want to install in your personal Linux account instead of under the system (due to multiple users issue)

    you can add --user flag

    $ pip --user install . # don't forget the dot, too
    

    Now, everything works fine on my laptop

    My configuration

    Ubuntu 16.04
    Python 2.7
    Numpy 1.13.1 
    

    Good luck!

提交回复
热议问题