Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing on Mac OSX #1

Closed
seanlaw opened this issue Jun 20, 2016 · 11 comments
Closed

Installing on Mac OSX #1

seanlaw opened this issue Jun 20, 2016 · 11 comments

Comments

@seanlaw
Copy link

seanlaw commented Jun 20, 2016

pip install implicit initially fails to find GCC since clang gcc is located in /usr/bin/gcc

After adding /usr/bin/gcc to setup.py I get:

gcc: error: implicit/_implicit.c: No such file or directory

I also tried installing gcc via Homebrew and installing from source:

python setup.py install

running install
running bdist_egg
running egg_info
writing requirements to implicit.egg-info/requires.txt
writing implicit.egg-info/PKG-INFO
writing top-level names to implicit.egg-info/top_level.txt
writing dependency_links to implicit.egg-info/dependency_links.txt
reading manifest file 'implicit.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'implicit/*.c'
writing manifest file 'implicit.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
running build_ext
building 'implicit._implicit' extension
gcc-6 -fno-strict-aliasing -I/Users/seanlaw/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/seanlaw/anaconda/include/python2.7 -c implicit/_implicit.c -o build/temp.macosx-10.5-x86_64-2.7/implicit/_implicit.o -fopenmp -ffast-math
gcc-6: error: implicit/_implicit.c: No such file or directory
gcc-6: fatal error: no input files
compilation terminated.
An exception has occurred, use %tb to see the full traceback.

SystemExit: error: command 'gcc-6' failed with exit status 1

Don't know if there were recent changes but it looks like implict/_implicit.c is missing

@benfred
Copy link
Owner

benfred commented Jun 20, 2016

Looks like I messed up on the install script =( will see about fixing tonight

As a short term hack to install, you can go 'cython implicit/_implicit.pyx' to generate the _implicit.c file, and then you should be able to install from source.

@titipata
Copy link

Hello @benfred, I still got error after doing cython implicit/_implicit.pyx follows by python setup.py install as follows:

...
building 'implicit._implicit' extension
gcc-6 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -I/Users/titipat/anaconda3/include/python3.5m -c implicit/_implicit.c -o build/temp.macosx-10.5-x86_64-3.5/implicit/_implicit.o -fopenmp -ffast-math
gcc-6: error: unrecognized command line option '-Qunused-arguments'; did you mean '-Wunused-argument'?
gcc-6: error: unrecognized command line option '-Qunused-arguments'; did you mean '-Wunused-argument'?
error: command 'gcc-6' failed with exit status 1

(I'm on Mac OSX also)

@benfred
Copy link
Owner

benfred commented Jun 23, 2016

@titipata Can you run this to see what the build flags are in your python install?

python -c 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))'

It should print out something like:

-fno-strict-aliasing -I/Users/ben/anaconda2/include -arch x86_64  -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

I think maybe the CFLAGS in your python install are messed up somehow. You can try to fix by tweaking the ' _sysconfigdata.py' file in your python library.

@titipata
Copy link

@benfred, here is an output when I run following command.

-fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/titipat/anaconda3/include -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -I/Users/titipat/anaconda3/include -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk

Here is output when I run gcc --version (installed with homebrew).

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I will thoroughly check what's the exact problem that I have.

@LanceVan
Copy link

LanceVan commented Jun 28, 2016

I guess the problem may sloved after you running brew install gcc --without-multilib.

I try to run pip install implicit with gcc install by brew install gcc, but failed.
OpenMP has conflict with multilib, so you should install gcc by brew install gcc --without-multilib

@benfred

Good luck!

benfred added a commit that referenced this issue Oct 6, 2016
OSX installs were failing if an openmp compatible compiler wasn't found,
backoff to using clang without openmp in this case
#1

On windows, we were passing in compile flags that weren't valid.
Visual Studo expects the '/W' flag to be an integer specifying the warning
level, and we were passing in a 'Wno-unused-function' to disable a warning.
#8 . Try to pass in the appropiate
options here
@benfred
Copy link
Owner

benfred commented Oct 6, 2016

We've tweaked the install script here recently - the compiled _implicit.c file is checked in, and I've changed the setup.py script to not require an openmp compatible compiler (if will just log an warning if it can't find one instead).

I think these issues should be resolved with these changes

@benfred benfred closed this as completed Oct 6, 2016
@isofer
Copy link

isofer commented Feb 17, 2017

Hi @benfred
Thanks for this great package.
I tried to build the package and failed. I'm getting the same error as @titipata.

$ python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to implicit.egg-info/requires.txt
writing implicit.egg-info/PKG-INFO
writing top-level names to implicit.egg-info/top_level.txt
writing dependency_links to implicit.egg-info/dependency_links.txt
reading manifest file 'implicit.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'implicit.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
running build_ext
building 'implicit._als' extension
creating build/temp.macosx-10.7-x86_64-2.7
creating build/temp.macosx-10.7-x86_64-2.7/implicit
g++-6 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -I/Users/imris/anaconda/envs/implicit/include/python2.7 -c implicit/_als.cpp -o build/temp.macosx-10.7-x86_64-2.7/implicit/_als.o -Wno-unused-function -Wno-maybe-uninitialized -O3 -ffast-math -fopenmp
g++-6: error: unrecognized command line option '-Qunused-arguments'; did you mean '-Wunused-argument'?
g++-6: error: unrecognized command line option '-Qunused-arguments'; did you mean '-Wunused-argument'?
error: command 'g++-6' failed with exit status 1

I re-installed gcc using brew install gcc --without-multilib as suggested by @LanceVan, but it didn't solve the problem.

Any suggestions?
Thanks

$ python -c 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))'
-fno-strict-aliasing -I/Users/imris/anaconda/envs/implicit/include  -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@benfred benfred reopened this Feb 17, 2017
@benfred
Copy link
Owner

benfred commented Mar 2, 2017

I don't know where those flags could be coming from - there are valid for Clang but not for GCC. =(

I thought that the flags get imported from the sysconfig.get_config_var("CFLAGS") setting in your python distribution - but it doesn't look that for your (the compile flags you printed out aren't included, and the incorrect ones are there instead). Maybe you can add a line to the setup.py file to go like 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))' just to make sure that this works.

Alternatively, if you uninstall the GCC compiler from brew (or comment out the 'set_gcc' function in setup.py) this should skip trying to find an openmp compiler and go with clang instead - which should work, just be single threaded

@azmaktr
Copy link

azmaktr commented May 10, 2017

Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-x50Fzy/implicit/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-02U13x-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-intel-2.7
    creating build/lib.macosx-10.11-intel-2.7/implicit
    copying implicit/__init__.py -> build/lib.macosx-10.11-intel-2.7/implicit
    copying implicit/als.py -> build/lib.macosx-10.11-intel-2.7/implicit
    copying implicit/nearest_neighbours.py -> build/lib.macosx-10.11-intel-2.7/implicit
    copying implicit/recommender_base.py -> build/lib.macosx-10.11-intel-2.7/implicit
    copying implicit/utils.py -> build/lib.macosx-10.11-intel-2.7/implicit
    running build_ext
    building 'implicit._als' extension
    creating build/temp.macosx-10.11-intel-2.7
    creating build/temp.macosx-10.11-intel-2.7/implicit
    g++-7 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c implicit/_als.cpp -o build/temp.macosx-10.11-intel-2.7/implicit/_als.o -Wno-unused-function -Wno-maybe-uninitialized -O3 -ffast-math -fopenmp
    g++-7: warning: x86_64 conflicts with i386 (arch flags ignored)
    g++-7: error: unrecognized command line option '-Wshorten-64-to-32'
    error: command 'g++-7' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-x50Fzy/implicit/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-02U13x-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-x50Fzy/implicit/

I have this error with GCC. Without GCC it works just fine.

@dillon-quan
Copy link

dillon-quan commented May 2, 2018

Hello @benfred, I'm trying to install the library but I am running into a similar error. The first time I tried installing the library I typed the given command line from the documentation "pip install implicit". A window then popped up asking me to if I would like to install gcc for the library in which I clicked install. This eventually gave me an error that came with a bunch of disable code and a gcc error.

I then try to install the library by cloning and I still get the following error stating that a random file is not found. Any thoughts on what I can do to fix this?

EDIT: It seems the way i installed gcc did not cut it. It had to be installed through homebrew.

Thanks

running install
running bdist_egg
running egg_info
writing implicit.egg-info/PKG-INFO
writing dependency_links to implicit.egg-info/dependency_links.txt
writing requirements to implicit.egg-info/requires.txt
writing top-level names to implicit.egg-info/top_level.txt
reading manifest file 'implicit.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*' found under directory 'examples'
writing manifest file 'implicit.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
running build_ext
building 'implicit.bpr' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda/include -arch x86_64 -I/anaconda/include -arch x86_64 -I/anaconda/include/python3.6m -c implicit/bpr.cpp -o build/temp.macosx-10.7-x86_64-3.6/implicit/bpr.o -Wno-unused-function -Wno-maybe-uninitialized -O3 -ffast-math -std=c++11
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean
'-Wno-uninitialized'? [-Wunknown-warning-option]
implicit/bpr.cpp:534:10: fatal error: 'random' file not found
#include
^
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

@travismsanders687
Copy link

@oppaquan I was getting this same error. Upgrading my OS (mac) fixed it. Basically my LLVM and clang where not up-to-date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants