Importing Pandas gives error AttributeError: module 'pandas' has no attribute 'core' in iPython Notebook

前端 未结 19 859
夕颜
夕颜 2020-11-30 09:50

I am running a iPython notebook via the Anaconda Navigator app (version 1.1.0). When I want to import pandas it gives me a strange error. I thought the Anaconda app included

19条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 10:25

    I had a similar issue since I installed pandas using python -m pip install pandas --upgrade --user which installed a conflicting version in my user python packages directory, masking the Anaconda installed version that other dependencies relied upon.

    conda list | grep pandas
    pandas == 0.23.4
    
    python -m pip list | grep pandas
    pandas == 0.24.0
    

    So uninstalling the user directory masked version cleaned up the issue for me.

    python -m pip uninstall pandas
    

    For reference all possible python packages are installed in the directories listed from this command:

    python -m site
    

    Might be worth iterating through these and checking for duplicates.

    Edit: Since my original answer I learnt you can run:

    python -m pip list -v
    

    And it shows the directory the library is installed. This often shows whether the library you want is in a virtual environment, conda environment, user directory, system site packages etc.

提交回复
热议问题