Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Python Numpy/Pandas installation?

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6.

I tried this

$ sudo easy_install pandas Searching for pandas Reading http://pypi.python.org/simple/pandas/ Reading http://pandas.pydata.org Reading http://pandas.sourceforge.net Best match: pandas 0.8.1 Downloading http://pypi.python.org/packages/source/p/pandas/pandas-0.8.1.zip#md5=d2c5c5bea971cd760b0ae6f6850fcb74 Processing pandas-0.8.1.zip Running pandas-0.8.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ckAMym/pandas-0.8.1/egg-dist-tmp-0mlL7t error: Setup script exited with pandas requires NumPy >= 1.6 due to datetime64 dependency 

So I tried to install Numpy

$ sudo easy_install numpy Searching for numpy Best match: numpy 1.6.2 Adding numpy 1.6.2 to easy-install.pth file  Using /Library/Python/2.6/site-packages Processing dependencies for numpy Finished processing dependencies for numpy 

So I tried again

$ sudo easy_install pandas 

But the problem is still the same !

error: Setup script exited with pandas requires NumPy >= 1.6 due to datetime64 dependency 

I run Python

$ python Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)  [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.__version__ '1.2.1' 

So Numpy 1.6 doesn't seems to be installed correctly !

I tried to install Numpy 1.6 with pip (instead of easy_install)...

$ sudo pip install numpy Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.6/site-packages Cleaning up... 

I added --upgrade flag

$ sudo pip install numpy --upgrade Requirement already up-to-date: numpy in /Library/Python/2.6/site-packages Cleaning up...  $ sudo pip install pandas Downloading/unpacking pandas   Downloading pandas-0.8.1.zip (1.9MB): 1.9MB downloaded   Running setup.py egg_info for package pandas     pandas requires NumPy >= 1.6 due to datetime64 dependency     Complete output from command python setup.py egg_info:     pandas requires NumPy >= 1.6 due to datetime64 dependency  ---------------------------------------- Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/pandas Storing complete log in /Users/MyUsername/Library/Logs/pip.log 

I also tried to install binary version of Numpy http://sourceforge.net/projects/numpy/files/ numpy-1.6.2-py2.6-python.org-macosx10.3.dmg but it fails !!! (installer said me that numpy 1.6.2 can't be install on this disk. Numpy requires python.org Python 2.6 to install.

like image 870
scls Avatar asked Sep 15 '12 11:09

scls


People also ask

How do I fix Python pandas?

Since pandas doesn't come installed automatically with Python, you'll need to install it yourself. The easiest way to do so is by using pip, which is a package manager for Python. In most cases, this will fix the error.

How do you're install pandas in Python?

Edit your . profile , or whatever is appropriate, and put /usr/local/bin at the start of your PATH so that Homebrew binaries are found before system binaries. brew install python - this installs a newer version of python in /usr/local. pip install pandas.

Do you need to install NumPy to use pandas?

Pandas is built on top of NumPy, which means the Python pandas package depends on the NumPy package and also pandas intended with many other 3rd party libraries. So we can say that Numpy is required for operating the Pandas.


2 Answers

Don't know if you solved the problem but if anyone has this problem in future.

$python >>import numpy >>print(numpy) 

Go to the location printed and delete the numpy installation found there. You can then use pip or easy_install

like image 77
tr33hous Avatar answered Sep 21 '22 05:09

tr33hous


I had this exact problem.

The issue is that there is an old version of numpy in the default mac install, and that pip install pandas sees that one first and fails -- not going on to see that there is a newer version that pip herself has installed.

If you're on a default mac install, and you've done pip install numpy --upgrade to be sure you're up to date, but pip install pandas still fails due to an old numpy, try the following:

$ cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/ $ sudo rm -r numpy $ pip install pandas 

This should now install / build pandas.

To check it out what we've done, do the following: start python, and import numpy and import pandas. With any luck, numpy.__version__ will be 1.6.2 (or greater), and pandas.__version__ will be 0.9.1 (or greater).

If you'd like to see where pip has put (found!) them, just print(numpy) and print(pandas).

like image 23
ricardo Avatar answered Sep 22 '22 05:09

ricardo