problem with installation on mac
kayhan-batmanghelich opened this issue · 4 comments
Hi Scott,
Thank you for sharing your code. I have some issues with installation on Mac and Linux (not the focus of this post). Here is what I get when I want to install it:
$ pip install -e .
[....]
Building wheels for collected packages: pypolyagamma, gslrandom
Running setup.py bdist_wheel for pypolyagamma ... error
Complete output from command /Users/kayhan/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/kh/s846jbks2539yqq9g1fs3fqr0000gn/T/pip-build-o1HhAA/pypolyagamma/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/kh/s846jbks2539yqq9g1fs3fqr0000gn/T/tmp_6UI33pip-wheel- --python-tag cp27:
running bdist_wheel
[...]
creating build/temp.macosx-10.5-x86_64-2.7/pypolyagamma
creating build/temp.macosx-10.5-x86_64-2.7/pypolyagamma/cpp
creating build/temp.macosx-10.5-x86_64-2.7/pypolyagamma/cpp/include
gcc -fno-strict-aliasing -I/Users/kayhan/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ipypolyagamma/cpp/include -I/usr/local/include -I/Users/kayhan/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/kayhan/anaconda/include/python2.7 -c pypolyagamma/pypolyagamma.cpp -o build/temp.macosx-10.5-x86_64-2.7/pypolyagamma/pypolyagamma.o -O0 -w -std=c++11 -fopenmp
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pypolyagamma
Running setup.py clean for pypolyagamma
Running setup.py bdist_wheel for gslrandom ... error
Complete output from command /Users/kayhan/anaconda/bin/python -u -c "import setuptools, t
[....]
building 'gslrandom.gslrandom' extension
creating build/temp.macosx-10.5-x86_64-2.7
creating build/temp.macosx-10.5-x86_64-2.7/gslrandom
gcc -fno-strict-aliasing -I/Users/kayhan/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -Igslrandom/ -I/Users/kayhan/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/kayhan/anaconda/include/python2.7 -c gslrandom/gslrandom.cpp -o build/temp.macosx-10.5-x86_64-2.7/gslrandom/gslrandom.o -O3 -w -std=c++11 -fopenmp
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gslrandom
Running setup.py clean for gslrandom
Failed to build pypolyagamma gslrandom
Installing collected packages: pypolyagamma, gslrandom, pylds, pgmult, funcsigs, pbr, mock
[....]
I/Users/kayhan/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/kayhan/anaconda/include/python2.7 -c pypolyagamma/pypolyagamma.cpp -o build/temp.macosx-10.5-x86_64-2.7/pypolyagamma/pypolyagamma.o -O0 -w -std=c++11 -fopenmp
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1
----------------------------------------
It seems that issue is with the compiler. Following this post:
http://stackoverflow.com/questions/29057437/compile-openmp-programs-with-gcc-compiler-on-os-x-yosemite
I gcc without --without-multilib
:
alias gcc='gcc-5'
alias g++='g++-5'
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.3.0/libexec/gcc/x86_64-apple-darwin15.4.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin15.4.0
Configured with: ../configure --build=x86_64-apple-darwin15.4.0 --prefix=/usr/local/Cellar/gcc/5.3.0 --libdir=/usr/local/Cellar/gcc/5.3.0/lib/gcc/5 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc 5.3.0 --without-multilib' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 5.3.0 (Homebrew gcc 5.3.0 --without-multilib)
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.3.0/libexec/gcc/x86_64-apple-darwin15.4.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin15.4.0
Configured with: ../configure --build=x86_64-apple-darwin15.4.0 --prefix=/usr/local/Cellar/gcc/5.3.0 --libdir=/usr/local/Cellar/gcc/5.3.0/lib/gcc/5 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew gcc 5.3.0 --without-multilib' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 5.3.0 (Homebrew gcc 5.3.0 --without-multilib)
but I still get the same error. It seems that the package still tries to use clang
(not sure?). Do you have any idea how to solve this issue?
Thanks,
Kayhan
another relevant post in stackoverflow:
http://stackoverflow.com/questions/36908426/compile-an-openmp-program-with-cmake-on-os-x
Hey Kayhan!
Setting a shell alias won't affect how the 'gcc' name gets resolved when python setup.py
calls it, and so it's likely that when you run the setup.py file it's still using clang to compile (hence the error message about clang).
You could either set the CC
environment variable or you could create a symbolic link in the filesystem somewhere on your PATH
. If you're using bash or zsh, to set the environment variables you can do something like
CC=$(which gcc-5) CXX=$(which g++-5) pip install -e .
assuming that which gcc-5
correctly resolves to the homebrew gcc binary you want to use.
Does that work? Or at least change the error message?
Hi Matt,
I think I resolved this issue so this issue is resolved. I thought you may want to add this to your readme file just in case someone else run into the same issue:
brew reinstall gcc --without-multilib
brew install gsl
export CC='gcc-5'
export CXX='g++-5'
you may also want to add the following depenencies to the readme file:
conda install --channel https://conda.anaconda.org/Chroxvi brewer2mpl
pip install git+https://github.com/mattjj/pyhsmm-autoregressive.git
pip install git+https://github.com/HIPS/hips-lib
Thanks,
Kayhan
ref: http://stackoverflow.com/questions/5967065/python-distutils-not-using-correct-version-of-gcc
Oop, Matt. Sorry I post it and then read your post. Thank you for your reply.
Glad to hear it's resolved! We'll try to make the readme clearer, and also root out any dependencies missing from the install_requires
list in setup.py.