32

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.

scls
  • 12,653
  • 9
  • 36
  • 49
  • Did you have a previous numpy installation? Maybe that messed things up. You should try to uninstall numpy and then reinstall the latest version. – Bakuriu Sep 15 '12 at 11:56
  • I have a previous of Numpy version 1.2.1 but I don't remember how this version was installed (from source, easy_install, pip, binary...). What is very strange is that I can't install binary (see the last part of my post I've just edited) – scls Sep 15 '12 at 12:28
  • 1
    Where is NumPy 1.2.1 installed (`import numpy as np; print np`)? I would suggest using a packaged distribution like EPDFree or Anaconda CE and avoid Apple's system Python if possible – Wes McKinney Sep 15 '12 at 13:08
  • `>>> import numpy as np >>> np.__version__ '1.2.1' >>> print(np) ` so I don't know how it has been installed – scls Sep 15 '12 at 18:05
  • 1
    That's nice Wes to suggest me to use EPD... I installed the Academic version (it seems to be better than EPD Free)... `$ sudo enpkg numpy` installed me numpy but `$ sudo enpkg pandas` returns `prefix: /Library/Frameworks/Python.framework/Versions/7.3 No egg found for requirement 'pandas'. Versions for package 'pandas' are: 0.2, 0.3.0, 0.4.3, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0rc2, 0.8.1 No subscription for 'pandas'` !!! – scls Sep 16 '12 at 17:55
  • figured it out: `pip install pandas` finds the version of `numpy` in the default mac install, and stops there - despite the fact that she's installed a newer version elsewhere. I put the steps to fix the problem in an answer below. – ricardo Dec 02 '12 at 00:09
  • I know this is old, but in situations like this, you should always check `which easy_install` and `which python` and make sure both commands are associated with the same framework / install! – Dav Clark Mar 06 '13 at 18:55
  • sometimes I just downgrade `pandas` in order to install the compatible version for specific `numpy`. – Ibrahim.H Jun 24 '19 at 18:45

9 Answers9

49

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

tr33hous
  • 1,540
  • 1
  • 13
  • 26
  • This also still works on Mavericks, just wanted to add that I had to delete the folder indicated as well as run `pip uninstall numpy`. Then running `pip install numpy` took care of it. – sofly Mar 14 '15 at 21:03
  • Thank you so much! I don't know why the default *numpy* for me went to the non-Anaconda version despite Anaconda being the default *Python* version for me ... – ComputerScientist Oct 05 '16 at 22:43
  • I do not think this solution resolve the problem, as it is often the case of not correctly set PATH directories. Moreover, this solution is package specific and it would be a huge hassle to do the same process for every package – Garini May 30 '18 at 08:58
  • 1
    Would `pip install --force-reinstall numpy` work as well? – Markus Mar 22 '19 at 07:14
10

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).

ricardo
  • 7,345
  • 6
  • 39
  • 64
  • 2
    Deleting things out of /System is a bad idea. – rspeer Jan 02 '13 at 19:40
  • @rspeer -- sure, but what else do you suggest? the OP asked how he could get around the fact that the pandas installer was finding the old version of numpy -- this fixes that problem. – ricardo Jan 02 '13 at 22:43
  • 1
    If your "only option" is to delete things out of System, then you should install a non-system python (unless you really know what you're doing, including the risks of future updates by Apple breaking things). However, as exhibited by the answer by @sjs, it's not the only option here. – Dav Clark Mar 06 '13 at 18:51
  • On my new 10.8.2 / dev pandas this is not a problem. I have had no problems with my 10.7.x laptop since hacking it to work in this way. – ricardo Mar 06 '13 at 19:24
  • there is always the option of moving/renaming a file to deleting it. – P.R. Nov 25 '14 at 02:35
8

I work with the guys that created Anaconda Python. You can install multiple versions of python and numpy without corrupting your system python. It's free and open source (OSX, linux, Windows). The paid packages are enhancements on top of the free version. Pandas is included.

conda create --name np17py27 anaconda=1.4 numpy=1.7 python=2.7
export PATH=~/anaconda/envs/np17py27/bin:$PATH

If you want numpy 1.6:

conda create --name np16py27 anaconda=1.4 numpy=1.6 python=2.7

Setting your PATH sets up where to find python and ipython. The environments (np17py27) can be named whatever you would like.

Bradley Kreider
  • 1,093
  • 10
  • 16
  • 2
    I've had an awful time working with Anaconda and multiple versions of Python -- it changed my default python distro and messed up dependencies in each version. I'd try to install it manually. – Razi Shaban Apr 27 '15 at 18:26
  • 1
    I'm sorry that happened. What do you mean by messing up dependencies? You should be able to uninstall Anaconda (it is only a directory) to reverse any changes. The installer should ask you if you want to make it the default for your shell. On OSX or Linux it does that by adding the PATH to your ~/.bash_profile. – Bradley Kreider Apr 29 '15 at 20:26
5

This worked for me under 10.7.5 with EPD_free-7.3-2 from Enthought:

Install EPD free, then follow the step in the following link to create .bash_profile file.

http://redfinsolutions.com/blog/creating-bashprofile-your-mac

And add the following to the file.

PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$(PATH)}"
export PATH

Execute the following command in Terminal

$ sudo easy_install pandas

When finished, launch PyLab and type:

In [1]: import pandas

In [2]: plot(arange(10))

This should open a plot with a diagonal straight line.

Toshi
  • 51
  • 1
  • 2
4

If you're like me and you don't like the idea of deleting things that were part of the standard system installation (which others have suggested) then you might like the solution I ended up using:

  1. Get Homebrew - it's a one-line shell script to install!
  2. 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
  3. brew install python - this installs a newer version of python in /usr/local
  4. pip install pandas

This worked for me in OS X 10.8.2, and I can't see any reason it shouldn't work in 10.6.8.

sjs
  • 6,520
  • 3
  • 17
  • 19
3

You probably have another Numpy version installed on your system, try to query your numpy version and retrieve it if your distribution does not support it.
aka debian/unbuntu/Mint version can query mostly from dpkg package manger : dpkg --get-selections | egrep -i "numpy", you can see actual Numpy version.

  • Some having apt can either asking to removing it by doing this: apt-get remove numpy.

  • Some having distribution like Fedora, RedHat and any compatible release under RedHat model can use rpm as well to query the installation.

  • This is happening by telling to Numpy installer to install itself in current /usr/local/lib/python[VERSION]/dist-packages over Linux env and c:[...]\python[VERSION]\site-packages for windows. Having probably One version of Numpy installed in /usr/local/python[VERSION]/dist-packages, this one will be instantiated first.

  • .pth file hold information about path location of specific python module, but erasing a component from packages may corrupt it...

Be careful, and you will have to remove the package and all it's dependency... really painful in some case.

Visiting lunchad.net may save you time sometimes they had new versions from some packages.

Asciiom
  • 9,409
  • 7
  • 35
  • 57
3

I had the same problem and, in my case, the problem was that python was looking for packages in some ordered locations, first of all the default computer one where default old packages are.

To check what your python is looking for you can do:

>>> import sys
>>> print '\n'.join(sys.path)

This was outputting the directory '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' before pip or brew or port folders.

The simple solution is:

export PYTHONPATH="/Library/Python/2.7/site-packages:$PYTHONPATH"

This worked well for me, I advise you to add this line to your home bash_profile file for the next time. Remember that sys.path is built using the current working directory, followed by the directories in the PYTHONPATH environment variable. Then there are the installation-dependent default dirs.

Garini
  • 814
  • 8
  • 29
2

If you are using a version of enthought python (EPD) you might want to go directly to your site-packages and reinstall numpy. Then try to install pandas with pip. You will have to modify your installation prefix for that.

If the problem persists (as it did with me) try downloading pandas tar ball, unpack it in your site packages and run setup.py install from your pandas directory.

If you got your dependencies right you can import pandas and check it imports smoothly.

Lynx-Lab
  • 745
  • 8
  • 17
1

he easiest way to install Pandas, like almost every other package for Python, is with pip.

Many packages (including Pandas) require a compiler, and a bunch of third-party DLLs, and many Windows users don't know how to deal with that. That's exactly why the "wheel" format was created: so packages can upload pre-built binaries.

Not every project has pre-built binary wheels for Windows yet. But you can look at Christoph Gohlke's site and find wheels for all of the most popular ones. Just follow the instructions on that page to download the wheel file and install it with pip.

But in the case of Pandas, you don't have to do that. They have wheels on their download page, and uploaded to PyPI. And the documentation tells you to use these. (Well, it first suggests you use Anaconda/Miniconda, but if you want a stock Python, use pip and the packages on PyPI.) it worked for me ...on windows 7 64 bit ,python 3.4