Pandas import gives AttributeError error: module 'pandas' does not have 'core' attribute in iPython Notebook

I am running an iPython laptop through the Anaconda Navigator app (version 1.1.0). When I want to import pandas, it gives me a strange error. I thought the Anaconda application included the pandas package?

--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-4-af55e7023913> in <module>() ----> 1 import pandas as pd /Users/bertcarremans/anaconda/lib/python3.5/site-packages/pandas/__init__.py in <module>() 37 import pandas.core.config_init 38 ---> 39 from pandas.core.api import * 40 from pandas.sparse.api import * 41 from pandas.stats.api import * /Users/bertcarremans/anaconda/lib/python3.5/site-packages/pandas/core/api.py in <module>() 8 from pandas.core.common import isnull, notnull 9 from pandas.core.categorical import Categorical ---> 10 from pandas.core.groupby import Grouper 11 from pandas.core.format import set_eng_float_format 12 from pandas.core.index import (Index, CategoricalIndex, Int64Index, /Users/bertcarremans/anaconda/lib/python3.5/site-packages/pandas/core/groupby.py in <module>() 16 DataError, SpecificationError) 17 from pandas.core.categorical import Categorical ---> 18 from pandas.core.frame import DataFrame 19 from pandas.core.generic import NDFrame 20 from pandas.core.index import (Index, MultiIndex, CategoricalIndex, /Users/bertcarremans/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in <module>() 37 create_block_manager_from_arrays, 38 create_block_manager_from_blocks) ---> 39 from pandas.core.series import Series 40 from pandas.core.categorical import Categorical 41 import pandas.computation.expressions as expressions /Users/bertcarremans/anaconda/lib/python3.5/site-packages/pandas/core/series.py in <module>() 33 from pandas.core.internals import SingleBlockManager 34 from pandas.core.categorical import Categorical, CategoricalAccessor ---> 35 import pandas.core.strings as strings 36 from pandas.tseries.common import (maybe_to_datetimelike, 37 CombinedDatetimelikeProperties) AttributeError: module 'pandas' has no attribute 'core' 
+14
source share
15 answers

Apparently, the error I received when trying to import pandas for the first time was ValueError: unknown locale: UTF-8

Trying to import again after that gave another error, as described in my question above.

I found a solution to solve ValueError on IPython local computer error

After updating my bash profile, the AttributeError: module 'pandas' has no attribute 'core' error no longer appears.

+9
source

Have you tried disabling it again and again? ” (Roy of the IT )

This happened to me today, and that is why I ended up on this page. Seeing that the error was strange since lately I haven't made any changes to my Python environment. Interestingly, I noticed that if I open a new laptop and import pandas I would not get the same error message. So, I shutdown nasty notebook and started it again and it works again!

Although this solved the problem (at least for me), I cannot readily explain why this happened in the first place!

+29
source

There is this error in the latest version of pandas (pandas 0.23), which gives you an error when importing pandas.

But this can be easily fixed by installing an earlier version of pandas (pandas 0.22) using the pip install pandas==0.22 command on the Windows command line.

+10
source

I just solved this problem. I recently changed my MacBook settings from English to English to Chinese. And I believe that this setting will also change the setting in "locale". When I switched back, I found that the locale setting was changed again, and I am right to import pandas again.

So, if you recently changed the language setting, you may need to change it.

+1
source

I recently encountered one problem right after installing Pandas 0.23 in Anaconda Prompt. The solution is to simply restart the Jupyter Notebook, which reports an error. Let it help.

+1
source

I had a similar problem since I installed pandas using python -m pip install pandas --upgrade --user which installed a conflicting version in my custom python package directory, masking the version of Anaconda that other dependencies relied on.

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

Thus, removing the masked version of the user directory fixed the problem for me.

 python -m pip uninstall pandas 

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

 python -m site 

It might be worth repeating them and checking for duplicates.

+1
source

You get this because you use Anaconda for Jupyter laptops. So just do conda install pandas restart your jupyter notebook and restart your camera. It should work. If you are trying this in a virtual environment, try this

  1. conda create -n name_of_my_env python This will create a minimal environment in which only Python will be installed. To put yourself in this environment, run:

2 source activate name_of_my_env On Windows, the command: activate name_of_my_env The last required step is to install pandas. This can be done using the following command:

conda install pandas To install a specific version of pandas:

conda install pandas=0.20.3

To install other packages, for example IPython:

conda install ipython To install the full Anaconda distribution:

conda install anaconda

If you need packages that are available for pip but not conda, then install pip, and then use pip to install these packages:

conda install pip pip install django Installing from PyPI Pandas can be installed via pip from PyPI.

pip install pandas Install using ActivePython

Hope this helps.

+1
source

I am facing a similar issue when importing TensorFlow . If you are using Tensorflow, which uses the Pandas library, I suggest restarting your kernel of Anaconda . This works for me.

+1
source

Try in console

 conda install pandas 

and see what message is indicated.

0
source

yes, Anaconda distribution includes pandas, type

 conda list 

to get a list of installed packages.

0
source
  • Press Ctrl + C to close the jupyter laptop, close all windows of the jupyter laptop.
  • Bring it back by typing jupyter notepad at the cmd prompt .
0
source

I had the same problem after installing the TensorFlow package, which downgraded my version of pandas from 2.23 to 2.22. I tried all the solutions suggested above + the messages suggested by the author related here . What ultimately worked for me was to reinstall the Anaconda distribution .

0
source

I ran into the same problem and solved it by following these steps:

  1. Open Anaconda Prompt [for Windows]
  2. Run "conda uninstall pandas".
  3. Run "conda install pandas".

In fact, there is a conflict with the pandas version, which will be automatically resolved by following the steps described above.

Stay Blessed!

0
source

There is another strange reason this is happening. If you have a file named pandas.py or a directory named pandas at the same or nested levels, this library is used instead and does not work. Rename the folder and restart env and it starts working. Faced this

0
source

You can try the command below

 conda upgrade --all 

and try restarting the laptop.

Hope this helps

0
source

All Articles