gmpy icon indicating copy to clipboard operation
gmpy copied to clipboard

Compile error when installing using pip

Open macdjord opened this issue 7 years ago • 6 comments

[root@foo ~]# pip install gmpy2
Collecting gmpy2
  Using cached gmpy2-2.0.8.zip
Installing collected packages: gmpy2
  Running setup.py install for gmpy2 ... error
    Complete output from command /usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sTLF5g/gmpy2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-eHgmfN-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'gmpy2' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DWITHMPFR -DWITHMPC -I/usr/include/python2.7 -c src/gmpy2.c -o build/temp.linux-x86_64-2.7/src/gmpy2.o
    In file included from src/gmpy2.c:426:0:
    src/gmpy.h:106:19: fatal error: gmp.h: No such file or directory
     #  include "gmp.h"
                       ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------

macdjord avatar Mar 07 '17 20:03 macdjord

You will need to install the development libraries for GMP, MPFR, and MPC.

casevh avatar Mar 07 '17 21:03 casevh

Be nice if that dependency were documented on the pypi page. Or better yet if the installer tested for that, and emitted a clear error message if they were missing.

macdjord avatar Mar 07 '17 23:03 macdjord

I've tried detecting if the development files are available but I encountered too many situations where I couldn't find them even though they were installed. I finally gave up.

I will improve the documentation on PyPi when I release 2.0.9. I can't edit the PyPi page directly anymore (or I can't figure out how do it).

casevh avatar Mar 08 '17 05:03 casevh

Add a C file which does nothing but #include one of the headers. Try to compile it. If it fails, the prereq is missing (or installed somewhere that GCC can't find it, which amounts to the same thing); emit an error message to that effect.

macdjord avatar Mar 09 '17 02:03 macdjord

You sholud try this : sudo apt-get install -y libgmp-dev libmpfr-dev libmpc-dev

lboue avatar Jul 05 '18 16:07 lboue

@casevh, I think this could be closed. Some instructions for installation of required libraries were added in 9db2dd7e3

skirpichev avatar Nov 28 '23 09:11 skirpichev