GMPY2 doesn't install

18,282

This is a bug in gmpy2 2.0.x series. It has been fixed in the currently development version. gmpy2 2.1.0a2 is available on PyPi but is hidden. The following commands will install it in a user-specific directory. Python will load modules from the user-specific directory first so the new version will shadow the provided version.

sudo apt install libmpc-dev
sudo apt install python3-pip
pip3 install --user gmpy2==2.1.0a2

The new version should be backwards compatible with the old version. But if you encounter any issues, you can remove the user-specific version as follows.

pip3 uninstall gmpy2==2.1.0a2

Share:
18,282
gypsyzz
Author by

gypsyzz

Updated on June 27, 2022

Comments

  • gypsyzz
    gypsyzz about 2 years

    EDIT: I'm using Win 10 and Ubuntu from the app store

    I have tried to install gmpy2 by using:

    apt-get install libgmp-dev
    apt-get install libmpfr-dev
    apt-get install libmpc-dev
    

    and also downloaded MPIR and compiled it. however using pip install gmpy2 still gives me the error

    c:\users\gypsyzz\appdata\local\temp\pip-install-l2hlf7q4\gmpy2\src\gmpy.h(104): fatal error C1083: Cannot open include file: 'mpir.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    

    in addition, i found that using the prebuilt wheel at https://www.lfd.uci.edu/~gohlke/pythonlibs/ does not give me any functions.

    import gmpy2
    from gmpy2 import mpz,mpq,mpfr,mpc
    gmpy2.conjugate(mpc())
    Traceback (most recent call last):
    
    File "<ipython-input-18-2d51a42bda9a>", line 1, in <module>
    gmpy2.conjugate(mpc())
    
    AttributeError: module 'gmpy2' has no attribute 'conjugate'
    

    I'm more certain that I have understood the functions wrongly for the last part, so please let me know the correct syntax.

    • Marc Glisse
      Marc Glisse about 6 years
      You seem to be mixing up linux and windows...
    • gypsyzz
      gypsyzz about 6 years
      @MarcGlisse Yes there's some mixing up. In Win 10 you can open ubuntu (not virtual client) with app store, and have an command prompt interface. I'm not sure how much of the software installations are shared to windows. I have an Ubuntu setup alongside now seeing how frustrating the situation is.
    • Marc Glisse
      Marc Glisse about 6 years
      No software is shared between ubuntu and windows. If you install GMP on linux, it is useless to python on windows.
    • gypsyzz
      gypsyzz about 6 years
      well then that explains, I'll stick to ubuntu for work then.
    • casevh
      casevh about 6 years
      And conjugate() is a method of the mpc type; not a function of the gmpy2 module. The following should work: gmpy2.mpc("1+2j").conjugate()
    • gypsyzz
      gypsyzz about 6 years
      @casevh yes I've tried that. but it crashes the ipython kernal. I'm using Ubuntu 18.04 python 3.6.5 and spyder3.
    • gypsyzz
      gypsyzz about 6 years
      using python command gives the same problem of crashing. code is import numpy as np import gmpy2 from gmpy2 import mpc mpc('1+2j').conjugate() and error is: Segmentation fault (core dumped)
    • casevh
      casevh about 6 years
      I can confirm the the bug. I'll work on a fix. Tracking at github.com/aleaxit/gmpy/issues/194