I'm trying to install gmpy2
in a virtual environment in Windows 10.
Initially, I was getting the following error.
Collecting gmpy2
Using cached https://files.pythonhosted.org/packages/90/f4/9a2e384b325b69bc5827b9a6510a8fb4a51698c915c06a3f25a86458892a/gmpy2-2.0.8.zip
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: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\gmpy2\\setup.py'"'"'; __file__='"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\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 'C:\Users\biles\AppData\Local\Temp\pip-record-p2f519dp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2'
cwd: C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\
Complete output (5 lines):
running install
running build
running build_ext
building 'gmpy2' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\gmpy2\\setup.py'"'"'; __file__='"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\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 'C:\Users\biles\AppData\Local\Temp\pip-record-p2f519dp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2' Check the logs for full command output.
I was able to go past this error by installing the Build Tools for Visual Studio from https://visualstudio.microsoft.com/downloads/.
I tried again and this time I got the following error.
Collecting gmpy2
Using cached https://files.pythonhosted.org/packages/90/f4/9a2e384b325b69bc5827b9a6510a8fb4a51698c915c06a3f25a86458892a/gmpy2-2.0.8.zip
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: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\gmpy2\\setup.py'"'"'; __file__='"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\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 'C:\Users\biles\AppData\Local\Temp\pip-record-i495p48z\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2'
cwd: C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\
Complete output (12 lines):
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DMPIR -DWITHMPFR -DWITHMPC -IC:\Workspace\path\to\project\venv\include -IC:\Users\biles\AppData\Local\Programs\Python\Python37-32\include -IC:\Users\biles\AppData\Local\Programs\Python\Python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcsrc\gmpy2.c /Fobuild\temp.win32-3.7\Release\src\gmpy2.obj
gmpy2.c
C:\Users\biles\AppData\Local\Temp\pycharm-packaging\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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\gmpy2\\setup.py'"'"'; __file__='"'"'C:\\Users\\biles\\AppData\\Local\\Temp\\pycharm-packaging\\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 'C:\Users\biles\AppData\Local\Temp\pip-record-i495p48z\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2' Check the logs for full command output.
I tried specifying the version to 2.1.0a4
and then to 2.1.0a2
and then to 2.0.8
. But I got the same error.
Note: I'm trying to install this package through PyCharm Settings -> Project Interpreter.
Installing gmpy2
in Windows 10
gmpy2
corresponding to your version of PythonInstall the wheel using the below-mentioned command.
pip install C:\path\to\wheel\gmpy2-2.0.8-cp37-cp37m-win32.whl
Using these steps I was able to successfully install gmpy2
in my virtual environment. Please refer to the following screenshot.
Note: In my case it was gmpy2-2.0.8-cp37-cp37m-win32.whl
because my project interpreter was Python 3.7
. The cp37
in the filename means CPython 3.7
. If you don't get the correct binaries, you'll get the following error.
gmpy2-2.0.8-cp38-cp38-win32.whl is not a supported wheel on this platform.
Thanks @keiv.fly :)