使用MS Visual C++编译器安装python gmpy时出错,适用于Python 2.7
我正在尝试通过 pip install gmpy
在一个使用 virtualenv 创建的测试环境中安装 gmpy,但遇到了错误。
我的笔记本电脑是 Windows 8.1 64位,使用的是 32位的 Python 2.7。
我安装了 Microsoft Visual C++ Compiler Package for Python 2.7,因为我之前收到了 unable to find vcvarsall.bat
的错误提示。安装了这个 C++ 编译器包并把 setuptools 升级到 7.0
后,这个错误提示消失了,但我又遇到了以下问题:
c:\envs\testenv1\build\gmpy\src\gmpy.h(30) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
error: command 'C:\\Users\\user_name\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
----------------------------------------
Cleaning up...
Removing temporary dir C:\envs\testenv1\build...
Command C:\envs\testenv1\Scripts\python.exe -c "import setuptools, tokenize;__file__='C:\\envs\\testenv1\\build\\gmpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\user_name\appdata\local\temp\pip-t4r7jf-record\install-record.txt --single-version-externally-managed --compile --install-headers C:\envs\testenv1\include\site\python2.7 failed with error code 1 in C:\envs\testenv1\build\gmpy
Exception information:
Traceback (most recent call last):
File "C:\envs\testenv1\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\envs\testenv1\lib\site-packages\pip\commands\install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "C:\envs\testenv1\lib\site-packages\pip\req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "C:\envs\testenv1\lib\site-packages\pip\req.py", line 706, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "C:\envs\testenv1\lib\site-packages\pip\util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command C:\envs\testenv1\Scripts\python.exe -c "import setuptools, tokenize;__file__='C:\\envs\\testenv1\\build\\gmpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\user_name\appdata\local\temp\pip-t4r7jf-record\install-record.txt --single-version-externally-managed --compile --install-headers C:\envs\testenv1\include\site\python2.7 failed with error code 1 in C:\envs\testenv1\build\gmpy
有人能给我指个方向吗?
我已经安装了以下内容:
Microsoft Visual 2008 Redistributable - x64 9.0.30729.6161
Microsoft Visual 2008 Redistributable - x86 9.0.30729.6161
Microsoft Visual 2010 x64 Redistributable - 10.0.40219
Microsoft Visual 2010 x86 Redistributable - 10.0.40219
Microsoft Visual 2012 Redistributable (x64) - 11.0.61030
Microsoft Visual 2012 Redistributable (x86) - 11.0.61030
Microsoft Visual C++ Compiler Package for Python 2.7
我不想安装 VS2008 或 MINGW。我希望“Microsoft Visual C++ Compiler Package for Python 2.7”能解决这个问题,但结果并没有。
2 个回答
0
我建议你在你的电脑上安装Anaconda这个工具。用Anaconda来安装gmpy2非常简单,它会自动处理所有需要的配件。你只需要在你的环境里输入这个命令:conda install gmpy2,几秒钟后就能安装好。
1
我在维护 gmpy
,我想说在Windows上构建 gmpy
和 gmpy2
是非常有挑战性的。你有没有想过为什么不能使用已经编译好的版本呢?因为 gmpy
和 gmpy2
只依赖一个DLL文件,所以如果需要的话,把它复制到其他地方其实是很简单的。