24

I'm having trouble installing the Python Pandas library on my Mac OSX computer.

I type the following in Terminal:

$ sudo easy_install pandas

But then I get the following:

Searching for pandas
Reading http://pypi.python.org/simple/pandas/
Reading http://pandas.pydata.org
Reading http://pandas.sourceforge.net
Best match: pandas 0.9.0
Downloading http://pypi.python.org/packages/source/p/pandas/pandas-
0.9.0.zip#md5=04b1d8e11cc0fc30ae777499d89003ec
Processing pandas-0.9.0.zip
Writing /tmp/easy_install-ixjbQO/pandas-0.9.0/setup.cfg
Running pandas-0.9.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ixjbQO/pandas-
0.9.0/egg-dist-tmp-EGREoT
warning: no files found matching 'setupegg.py'
no previously-included directories found matching 'doc/build'
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '*.png' found anywhere in distribution
unable to execute gcc: No such file or directory
error: Setup script exited with error: command 'gcc' failed with exit status 1

I do have Xcode and gcc installed, however, gcc is only found when I type:

$ gcc
-bash: gcc: command not found

$ gcc-4.2
i686-apple-darwin11-gcc-4.2.1: no input files

What should I do?

Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
mpjan
  • 1,790
  • 5
  • 18
  • 21

13 Answers13

43

Install pip.

Then install pandas with pip:

pip install pandas
Code Maverick
  • 20,171
  • 12
  • 62
  • 114
user2335754
  • 431
  • 4
  • 4
18

You can install python with homebrew:

brew install python

Make sure that OSX uses the correct path:

which python

Then you can use the pip tool to install pandas:

pip install pandas

Make sure that all dependencies are installed. I followed this tutorial: http://penandpants.com/2013/04/04/install-scientific-python-on-mac-os-x/

Works fine on my machine.

peterlih
  • 181
  • 1
  • 2
9

You need to install XCode AND you need to make sure you install the command line tools for XCode so you can get gcc.

Chang She
  • 16,692
  • 8
  • 40
  • 25
8

Try

pip3 install pandas 

from terminal. Maybe your original pip install pandas is referencing anaconda distribution

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Ajinkya
  • 1,797
  • 3
  • 24
  • 54
4

I would recoment using macport or fink to install pandas:

  1. Install XCode from App Store, this will install 3 compilers, clang, gcc ("apple") and gcc ("normal")
  2. Install macports (www.macports.org) or fink (www.finkproject.org)
  3. Never use your mac python again, and install all python modules trough the fink/macport and enjoy it taking care dependencies for you.

Installing pandas in macports is as simple as: sudo port install py27-pandas

you usualy install macport in /opt/local and fink in /sw, I would advice (though this may be bad advice) you to symlink your fink/mac ports python to your system python as follows such that: /usr/bin/python -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

jcr
  • 1,015
  • 6
  • 18
4

In Mac terminal (we can launch Mac Terminal by searching in spotlight search Command + space) Now, use the command:

pip3 install pandas

As I'm using Python Version 3 I need to use pip3 install pandas.

If you are using python version 2 than use Command:

pip install pandas

Make sure pip is already installed in the device

sameer
  • 443
  • 4
  • 9
2

pip install pandas works fine with pip 18.0 on macOS 10.13.6. In addition, to work with Xlsx files, you will need xlrd installed.

Sathish
  • 1,245
  • 2
  • 15
  • 22
1

Not an innovative way but below two steps might save a ton of time and energy.

  1. Updating (Installing Command Line Tool) Code.

This can be done by openinig XCode -> Menu -> Preference -> Components -> Command Line Tool

  1. Removing all but Python 2.7

I did installed different instances of python at different time and removing all but 2.7 was helpful in my case. Note : You may have to install modules after doing it. So get ready with pip/easy_install/ports.

Uninstall can be done with super easy steps mentioned in following link.

How to uninstall Python 2.7 on a Mac OS X 10.6.4?

Community
  • 1
  • 1
LonelySoul
  • 1,212
  • 5
  • 18
  • 45
0

I believe you need a sim link

$ ln -s gcc gcc-4.2

This should tell your terminal to call gcc-4.2 when you run $ gcc.

Climbs_lika_Spyder
  • 6,004
  • 3
  • 39
  • 53
0

You need to install newest version of xCode from appStore. It contains the compiler for C(gcc) and C++(g++) for mac. Then you can install pandas without any problem. Use the following commands in terminal:

  1. xcode-select --install

  2. pip3 install pandas

It might take some time as it installs other packages too. Please be patient.

0

Write down this and try to import pandas again!

import sys
!{sys.executable} -m pip install pandas

It worked for me, hope will work for you too.

0

for Mac run the given command in terminal

sudo easy_install pip
pip3 install pandas

if you want to install pandas profiling then run

pip3 install pandas-profiling
Reza Rahemtola
  • 1,182
  • 7
  • 16
  • 30
-1

pip install worked for me, and it failed with a permission issue, which was resolved when I used

sudo pip install pandas

I see that the best sudo workaround is from /tmp: Is it acceptable and safe to run pip install under sudo?

NKR
  • 21
  • 5
  • I would like to ask why this answer was down voted? It also did not work for me and my (and I think many other people's) reflex was to use sudo. – RobinDeCroon Aug 01 '17 at 09:59
  • You'd better not use sudo for python package install in mac – Olivia Liao Feb 03 '18 at 15:37
  • can you explain more ? Why do you think sudo pip on Mac is not good ? I see various discussions around this, but nothing solid. – NKR Feb 04 '18 at 19:47