Ask coding questions

← Back to all posts
gmpy2 help python
adl212 (172)

Hi, it seems like whenever I try installing the package gmpy2 in python, it results with an error. Does anyone have an idea on how to install it without an error?

Comments
hotnewtop
Coder100 (18144)

For future people: use gmpy if you really need to use gmpy, hopefully it has similar features

adl212 (172)

@Coder100 Here's the whole thing:

Repl.it: Updating package configuration

--> python3 -m poetry add gmpy2
Using version ^2.0.8 for gmpy2

Updating dependencies
Resolving dependencies...

Writing lock file


Package operations: 1 install, 0 updates, 0 removals

  - Installing gmpy2 (2.0.8)

[EnvCommandError]
Command ['/opt/virtualenvs/python3/bin/pip', 'install', '--no-deps', 'gmpy2==2.0.8'] errored with the following return code 1, and output: 
Collecting gmpy2==2.0.8
  Downloading gmpy2-2.0.8.zip (280 kB)
Building wheels for collected packages: gmpy2
  Building wheel for gmpy2 (setup.py): started
  Building wheel for gmpy2 (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /opt/virtualenvs/python3/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0yfvyv0m/gmpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0yfvyv0m/gmpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-s3avtshq
       cwd: /tmp/pip-install-0yfvyv0m/gmpy2/
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'gmpy2' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITHMPFR -DWITHMPC -I/opt/virtualenvs/python3/include -I/usr/include/python3.8 -c src/gmpy2.c -o build/temp.linux-x86_64-3.8/src/gmpy2.o
  In file included from src/gmpy2.c:426:0:
  src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory
   #  include "mpfr.h"
              ^~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for gmpy2
  Running setup.py clean for gmpy2
Failed to build gmpy2
Installing collected packages: gmpy2
    Running setup.py install for gmpy2: started
    Running setup.py install for gmpy2: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /opt/virtualenvs/python3/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0yfvyv0m/gmpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0yfvyv0m/gmpy2/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-record-fp56vblq/install-record.txt --single-version-externally-managed --compile --install-headers /opt/virtualenvs/python3/include/site/python3.8/gmpy2
         cwd: /tmp/pip-install-0yfvyv0m/gmpy2/
    Complete output (14 lines):
    running install
    running build
    running build_ext
    building 'gmpy2' extension
    creating build
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITHMPFR -DWITHMPC -I/opt/virtualenvs/python3/include -I/usr/include/python3.8 -c src/gmpy2.c -o build/temp.linux-x86_64-3.8/src/gmpy2.o
    In file included from src/gmpy2.c:426:0:
    src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory
     #  include "mpfr.h"
                ^~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/virtualenvs/python3/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0yfvyv0m/gmpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0yfvyv0m/gmpy2/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-record-fp56vblq/install-record.txt --single-version-externally-managed --compile --install-headers /opt/virtualenvs/python3/include/site/python3.8/gmpy2 Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available.
You should consider upgrading via the '/opt/virtualenvs/python3/bin/python3 -m pip install --upgrade pip' command.

exit status 1


Repl.it: Package operation failed.
Coder100 (18144)

oh, it failed to build @adl212

Coder100 (18144)

eh, repl.it's bad
report this to bugs. Thanks!
@adl212

Coder100 (18144)

send link i want to upvote @adl212

adl212 (172)

@Coder100 Well, I'm now using gmpy which works. This really helps me on the prime fibonacci weekly challenge!