0

I have been experiencing the following problem with pandas for days: I can import pandas when I use spyder but it does not work when I use ipython or jupyter. I have been looking in several directions to solve the problem:

  • I have updated pandas,
  • I have checked that ipython and spyder have the same pythonpath,
  • I have uninstalled and reinstalled spyder

It still does not work and I get the following error message:

ImportError                               Traceback (most recent call last)
<ipython-input-8-d6ac987968b6> in <module>()
----> 1 import pandas

/Users/ME/anaconda/lib/python2.7/site-packages/pandas/__init__.py in <module>()
     29                       "pandas from the source directory, you may need to run "
     30                       "'python setup.py build_ext --inplace' to build the C "
---> 31                       "extensions first.".format(module))
     32 
     33 from datetime import datetime

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

I see that other people had the same problem but there is no clear answer. Does anyone know the procedure to solve it ?

Jb_Eyd
  • 635
  • 1
  • 7
  • 20
  • This doesn't help? http://stackoverflow.com/questions/30761152/how-to-solve-import-error-for-pandas – IanS May 03 '16 at 09:25
  • No it does not work. Sadly. – Jb_Eyd May 03 '16 at 12:18
  • How did you update pandas? (conda? pip?) What version? Does pandas work from an ipython/python prompt? – Back2Basics May 03 '16 at 21:49
  • @Back2Basics: I have updated pandas using "pip install --upgrade pandas". I have pandas 0.18.0. Pandas does work from the ipython/python prompt available on spyder BUT it does not work on the classic ipython/python prompt (the one opened from the terminal). – Jb_Eyd May 04 '16 at 11:50
  • since you are using anaconda I would suggest using their install tool called "conda". so try a "conda update pandas spyder ipython" – Back2Basics May 05 '16 at 03:16

1 Answers1

0

I found the solution: the error comes from a value error due to an encoding problem.

It happens quite a lot in python and various questions have been asked about it. Among them, the following link explains it carefully:

Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"

To be short, one only needs to run the following bash code to solve the problem:

echo -e "export LC_ALL=en_US.UTF-8\nexport LANG=en_US.UTF-8" >> ~/.bashrc && source ~/.bashrc
Community
  • 1
  • 1
Jb_Eyd
  • 635
  • 1
  • 7
  • 20