4

I want to install pandas on MAC OS X 10.7 with Python 2.7 with "sudo pip install pandas". Some of the output I'm getting:

Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pandas/index.c -o build/temp.macosx-10.7-intel-2.7/pandas/index.o
    In file included from pandas/index.c:317:
    pandas/src/numpy_helper.h: In function ‘infer_type’:
    pandas/src/numpy_helper.h:32: error: ‘PyDatetimeArrType_Type’ undeclared (first use in this function)
    pandas/src/numpy_helper.h:32: error: (Each undeclared identifier is reported only once
    pandas/src/numpy_helper.h:32: error: for each function it appears in.)
    pandas/src/numpy_helper.h: In function ‘get_datetime64_value’:
    pandas/src/numpy_helper.h:53: error: ‘PyDatetimeScalarObject’ undeclared (first use in this function)
    pandas/src/numpy_helper.h:53: error: expected expression before ‘)’ token
    pandas/src/numpy_helper.h: In function ‘is_datetime64_object’:
    pandas/src/numpy_helper.h:84: error: ‘PyDatetimeArrType_Type’ undeclared (first use in this function)
    pandas/src/numpy_helper.h: In function ‘is_timedelta64_object’:
    pandas/src/numpy_helper.h:89: error: ‘PyTimedeltaArrType_Type’ undeclared (first use in this function) 

And I get this:

lipo: can't open input file: /var/tmp//ccaW8SVp.out (No such file or directory)

error: command 'llvm-gcc-4.2' failed with exit status 1

All the dependencies (NumPy, pythondateutil, pytz) are working fine. I've also the latest version of the Command Line Tools as suggested here: Why am I getting the error: command 'llvm-gcc-4.2' failed with exit status 1 and here gcc-4.2 failed with exit status 1

I think my question is strongly related to this (not helping) post: Issues with installing pandas in python in MAC

And now I'm out of options and have really no idea what to do :-( Except asking for help... So thanks in advance!

Community
  • 1
  • 1
los_floppos
  • 117
  • 2
  • 7
  • 1
    how are you trying to build/install pandas? Did you download the source, use `pip`, Homebrew, MacPorts...? – MattDMo Dec 14 '13 at 17:46
  • Oh. This was fast. I'm using "sudo pip install pandas". I edited the question. – los_floppos Dec 14 '13 at 17:47
  • What version of Python do you have? Have you installed it from python.org, or are you using the default system version? – MattDMo Dec 14 '13 at 17:49
  • I'd recommend that you use [conda](http://docs.continuum.io/conda/) to install pandas/scipy/sklearn. That way you don't have to deal with building the C extensions. – TomAugspurger Dec 14 '13 at 17:50
  • @MattDMo It's Python 2.7. And I used one from here: http://www.python.org/download/ – los_floppos Dec 14 '13 at 17:53
  • If you run `head -1 \`which pip\`` from the command line, what does it return? It's possible that `pip` is using the system Python instead of the python.org version. – MattDMo Dec 14 '13 at 17:57

4 Answers4

6

For me, the following fixed it:

sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/
sudo pip install --upgrade numpy
sudo pip install pandas

I noticed that Pandas was trying to link against an older version of numpy under Frameworks, rather than the newer one under /Library/Python/2.7/site-packages

Boris M
  • 61
  • 2
1

It takes a little while to set up, but I've found MacPorts to be extremely useful in installing third-party modules. In my experience it has many more packages available than Homebrew, and the dependencies are installed with a lot less fuss and bother than trying to do it yourself. Check out the Quick Start for how to install.

Once it's installed, restart your Terminal session, and check your PATH (echo $PATH) to ensure that /opt/local/bin is before /usr/bin and /Library/Frameworks/Python.framework/Versions/2.7/bin. Then, you can run sudo port install py27-pandas to get Python and all of the dependencies installed.

The drawback of installing MacPorts is that any packages you've installed using the python.org version of Python won't be available. The easiest way around this is to reinstall them using MacPorts, or if they're not available as a port, using the MacPorts version of pip.

Good luck!

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • Ok. This is how my env PATH looks like: `PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/MacGPG2/bin` So `/opt/local/bin` is before `/usr/bin` with `/Library/Frameworks/Python.framework/Versions/2.7/bin` missing. Though after running `sudo port install py27-pandas` everthing seems to be installed smouthly but after I try to import pandas I get: `ImportError: cannot import name urandom` Though I check if I use the correct Python with `>>> import sys >>> from pprint import pprint as pp >>> pp(sys.path)` Any ideas? – los_floppos Dec 16 '13 at 00:09
  • Can you post the full text of the traceback from the ImportError in the text of your question? It'll help figure out where the problem is. – MattDMo Dec 16 '13 at 00:24
0

Update: I finally managed to get it installed (with the help of others I should add...!). I am not sure if I remember everything I did correctly and extensively, but here are some pointers:

I think the point is that the numpy version you have should be => 1.6 in order for pandas to be able to install properly. However the default Python installation provided by Apple only allows for numpy up to version 1.5.1. It might be, BTW, that there is more or other reasons why pandas doesn't like the Mac OS X provided Python, but the point remains that you need another Python version.

So, I downloaded and installed a Python 2.7.6 version from Python.org.

Then you can "pip install --upgrade numpy" and it will be numpy 1.8.

NOTE If '$ which python' gives you the new Python.org Python 2.7.6 version, you might want to say '$ python pip install ...' as the first line of pip contains the default '/usr/bin/python' so that will install whatever it is your're installing for the "old" default Python version.

NOTE that you should also upgrade/reinstall scipy, if you use it, so the numpy and scipy version correspond to one another.

I hope this is of any avail to anyone...!

Tom
  • 2,769
  • 2
  • 17
  • 22
0

It's very strange.

It seems the default python 2.7 with OSX can not install pandas well.

I just install python 3.3 and then it works.

pythonbrew switch Python-3.3.1

pip install pandas