Skip to content

Instantly share code, notes, and snippets.

@goldsmith
Last active January 6, 2024 07:25
Show Gist options
  • Save goldsmith/7262122 to your computer and use it in GitHub Desktop.
Save goldsmith/7262122 to your computer and use it in GitHub Desktop.
How to install Numpy and Scipy on Mac OS X Mavericks (10.9) using Pip.
# set up flags for Numpy C extentions compiling
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export CC=gcc-4.2
export CXX="g++ -arch i386 -arch x86_64"
pip install numpy
# success!
# now for scipy
easy_install cython
# make sure you have Homebrew
brew install gfortran
# if this is too slow or has an error
# install gfotran from the Mac OS X Lion installer for Intel 64-bit processors
# http://gcc.gnu.org/wiki/GFortranBinaries#MacOS
# finally
pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev
# Let me know if this works for you! jhghank@gmail.com
@rushter
Copy link

rushter commented Nov 4, 2013

Thank you, this solution works for me.

@aabdullah-bos
Copy link

This also worked for me. Thanks so much. I did however have to make one change, I had to quote the line that exported CXX:

export CXX="g++ -arch i386 -arch x86_64"

I am pretty sure that I've got other issues, but gcc didn't work for me. I wound up replacing gcc and g++ with clang.

@goldsmith
Copy link
Author

Good catch, it should have been quoted.

@eclipselu
Copy link

It works, thank you

@oguzhan
Copy link

oguzhan commented Nov 30, 2013

thanks !

@TheCorp
Copy link

TheCorp commented Jan 2, 2014

This didn't work for me, I ran into issues on the final step with errors like these when compiling

/System/Library/Frameworks/vecLib.framework/Headers/vBasicOps.h:153:23: error: immintrin.h: No such file or directory

Ended up going with this - http://fonnesbeck.github.io/ScipySuperpack/

@aa403
Copy link

aa403 commented Jan 3, 2014

quick question - which version of numpy does this install?

@fogathmann
Copy link

Excellent, thank you!

On my system (Mavericks 10.9.2 with latest update for Command Line Tools) I had to use

export CC=gcc

rather than

export CC=gcc-4.2

@svdgraaf
Copy link

@fogathmann 👍 I had the same issue, works like a charm!

@scw
Copy link

scw commented Apr 3, 2014

I've been having this same problem, for pretty much any packages which build C/C++ code. I made a small wrapper around this process so that pip gets the right environment directly. It seems to work OK for me, and makes it less annoying to manage the shell variables on a per-session basis.

@llvll0hsen
Copy link

I have some problem with Cpython . any got any solution:
Searching for cython
Reading http://pypi.python.org/simple/cython/
Best match: Cython 0.20.1
Downloading https://pypi.python.org/packages/source/C/Cython/Cython-0.20.1.tar.gz#md5=52431696c64e618036537c4d9aa79d99
Processing Cython-0.20.1.tar.gz
Running Cython-0.20.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P4GGuh/Cython-0.20.1/egg-dist-tmp-SNjzLk
warning: no files found matching '.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '
.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '
.pxd' under directory 'Cython/Utility'
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: Setup script exited with error: command 'cc' failed with exit status 1

@goldsmith
Copy link
Author

try this?

export CFLAGS="-arch i386 -arch x86_64 -Qunused-arguments"
export CPPFLAGS="-Qunused-arguments"

@entryword
Copy link

Thanks a lot!
and thank you @fogathmann it works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment