Search code examples
pythongmpy

GMPY2 install: DLL load failed: %1 is not a valid Win32 application


I tried to install gmpy2 on my python distribution (Anaconda 64bit) and I did this by downloading the precompiled .PYD file from http://www.lfd.uci.edu/~gohlke/pythonlibs and put the file in the site-packages folder (I tried this with both the 32 bit and 64 bit versions). However when I ran it and tried to import gmpy2 it gave the following error: DLL load failed: %1 is not a valid Win32 application. I do not know how to fix this as everything I am using is 64 bit. I have looked at some of the other answers on this site but none of them seem to help. Does anyone know what I might try to do?


Solution

  • After downloading the GMPY wheel file from Christoph Gohlke's site, you need to open a command window and change to the folder where you downloaded GMPY, and use pip to install it:

    ~\Downloads\> pip install gmpy2‑2.0.5‑cp27‑none‑win_amd64.whl
    

    If you don't have pip, use conda to install it first:

    ~> conda install setuptools pip
    

    Note: I used the tilde to represent C:\Users\<username>\.