Import pandas on jupyter ipython notebook not working

I can import the pandas package inside the spyder ide; however, if I try to open a new juypter laptop, import will fail.

I am using Anaconda package distribution on MAC OS X.

That's what I'm doing:

In [1]: import pandas 

and this is the answer I get:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-97925edf8fb0> in <module>()
----> 1 import pandas

//anaconda/lib/python2.7/site-packages/pandas/__init__.py in <module>()
     11                       "pandas from the source directory, you may need to run "
     12                       "'python setup.py build_ext --inplace' to build the C "
---> 13                       "extensions first.".format(module))
     14 
     15 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.
+4
source share
2 answers

You have several Python 2 engines installed. One on your main OS platform, the other in Anaconda's virtual environment. You need to install Panda on the latter.

Run the Bash command prompt:

which python

Then run the following in Jupyter / IPython and compare the result with the output obtained from the Bash script:

from sys import executable
print(executable)

, (.. ), Bash :

<the 2nd output> -m pip install pandas

:

/usr/bin/anaconda/python2 -m pip install pandas

Pandas Anaconda Python.

, sys.path.append('path to alternative locations'), , , .

:

python -m pip install cython scipy panda matplotlib jupyter notebook ipython

Update:

:

homebrew :

:

xcode-select --install

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

:

brew doctor
brew update
brew upgrade

Python 2 Brew:

brew install python

Python 3

brew install python3

. !

brew install git conda gfortran clang pkg-config

brew, pip, , pip.

easy_install pip

Python (NumPy SciPy, SciPy Matplotlib Cython C, Scipy fortran ODE):

python2 -m install cython scipy pandas matplotlib jupyter

Python 3.

. , Python Python.org . brew - , , . Python 2, brew. OS X. , -. OS X , . , , brew install python3.

+6

Mac OS X Anaconda (Python 2). pandas python repl :

ValueError: unknown locale: UTF-8

~/.bash_profile:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

.

+5

Source: https://habr.com/ru/post/1627658/


All Articles