Notebook: Errors when importing pandas.

Created on 24 May 2017  路  5Comments  路  Source: jupyter/notebook

I have pandas installed in my default python site-packages folder. When importing pandas in Pycharm, everything goes smoothly:
in:
import pandas as pd
out:

  `C:\Users\sx449_000\AppData\Local\Programs\Python\Python36-32\python.exe 
   C:/Users/sx449_000/PycharmProjects/untitled/ML.py

Process finished with exit code 0`

However, problem occurs when importing pandas in Jupyter Notebook:
In: import numpy as np import matplotlib as plt import pandas as pd
Out:

 `---------------------------------------------------------------------------
 ModuleNotFoundError                       Traceback (most recent call last)
 C:\Users\sx449_000\AppData\Roaming\Python\Python36\site-packages\pandas\__init__.py in 
  <module>()
 25 try:
  ---> 26     from pandas._libs import (hashtable as _hashtable,
 27                              lib as _lib,

  C:\Users\sx449_000\AppData\Roaming\Python\Python36\site-packages\pandas\_libs\__init__.py in 
  <module>()
  2 
   ----> 3 from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
  4 

  ModuleNotFoundError: No module named 'pandas._libs.tslib'

  During handling of the above exception, another exception occurred:

  ImportError                               Traceback (most recent call last)
  <ipython-input-8-79633c9e0bf8> in <module>()
  1 import numpy as np
  2 import matplotlib as plt
  ----> 3 import pandas as pd

 C:\Users\sx449_000\AppData\Roaming\Python\Python36\site-packages\pandas\__init__.py in 
  <module>()
 33                       "pandas from the source directory, you may need to run "
 34                       "'python setup.py build_ext --inplace --force' to build "
 ---> 35                       "the C extensions first.".format(module))
 36 
 37 from datetime import datetime

  ImportError: C extension: No module named 'pandas._libs.tslib' 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.`

I tried to uninstall then reinstall pandas through Pycharm Interpreter setting several times but the problem remains.

Most helpful comment

I just spent so much time behind this. All i had to do was uninstall and install Pandas to get latest version
conda uninstall pandas
conda install pandas

This solved my problem.. In older days the solution for any windows problem is uninstall and install.. same applies here as well 馃憤

All 5 comments

Hi all,

I'm having the same issues above - when I try to do:
import pandas as pd,

I get the following:

ModuleNotFoundError Traceback (most recent call last)
~\AppData\Roaming\Python\Python36\site-packages\pandas__init__.py in ()
25 try:
---> 26 from pandas._libs import (hashtable as _hashtable,
27 lib as _lib,

~\AppData\Roaming\Python\Python36\site-packages\pandas_libs__init__.py in ()
3
----> 4 from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
5

ModuleNotFoundError: No module named 'pandas._libs.tslib'

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in ()
----> 1 import pandas as pd

~\AppData\Roaming\Python\Python36\site-packages\pandas__init__.py in ()
33 "pandas from the source directory, you may need to run "
34 "'python setup.py build_ext --inplace --force' to build "
---> 35 "the C extensions first.".format(module))
36
37 from datetime import datetime

ImportError: C extension: No module named 'pandas._libs.tslib' 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.

I have tried installing anaconda multiple times, miniconda as well.
Now I'm back to anaconda and have set up the environment path myself.
But not sure how to solve this error after trying to follow the recommended steps.

Have been stuck for 2 days, any help would be much appreciated.

Thanks,

Current paths are C:\Users\User\Anaconda3;C:\Users\User\Anaconda3\Scripts;C:\Users\User\Anaconda3\pkgs;C:\Users\User\AppData\Roaming\Python\Python36\site-packages

I just spent so much time behind this. All i had to do was uninstall and install Pandas to get latest version
conda uninstall pandas
conda install pandas

This solved my problem.. In older days the solution for any windows problem is uninstall and install.. same applies here as well 馃憤

This solved my probelm. thanks yasimk.
conda uninstall pandas
conda install pandas

In Jupiter Notebook
write the code- In[1] import pandas as pd but this type of error on output
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import pandas as pd

ModuleNotFoundError: No module named 'pandas'

Was this page helpful?
0 / 5 - 0 ratings