我正在尝试将OpenEXR的python绑定安装(编译)到我的模块。
首先,我简单地尝试了pip install openexr
,这是由于C ++安装的OpenEXR缺少头文件而导致的错误。因此,我通过它安装了vcpkg和OpenEXR。由于来自Python绑定的OpenEXR.cpp中的语法错误,执行pip install --global-option=build_ext --global-option="-IC:\vcpkg\packages\openexr_x86-windows\include\OpenEXR" --global-option="-LC:\vcpkg\packages\openexr_x86-windows\lib" openexr
失败。我从https://pypi.org/project/OpenEXR/#files手动下载了该模块,并尝试安装/编译该模块,这在同一文件中导致相同的语法错误。我的Visual Studio在文件中没有发现任何问题,因此我认为问题一定是pip用于安装该模块的C ++编译器。我已经安装了构建工具2019,并添加了2017构建工具,但它无济于事。我想我必须指定要使用的编译器,但是在这里我找不到任何有关这样做的示例...
我的问题:您如何指定编译器使用哪个pip来安装模块?
- Windows 10
- Python 3.8.0
- 已安装VC 2019 C ++ x64 / x86 Buildtools
- 已安装VC 2017 C ++ x64 / x86 Buildtools
- 通过vcpkg安装的OpenEXR(C ++)
编辑:
语法错误
C:\Users\alexa\PycharmProjects\Test\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\commands\install.py:207: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting openexr
Using cached https://files.pythonhosted.org/packages/7c/c4/76bf884f59d3137847edf8b93aaf40f6257d8315d0064e8b1a606ad80b1b/OpenEXR-1.3.2.tar.gz
Installing collected packages: openexr
Running setup.py install for openexr ... error
Complete output from command C:\Users\alexa\PycharmProjects\Test\venv\Scripts\python.exe -u -c "import setuptools,tokenize;__file__='C:\\Users\\alexa\\AppData\\Local\\Temp\\pip-install-81q20tqc\\openexr\\setup.py';f=getattr(tokenize,'open',open)(__file__);code=f.read().replace('\r\n','\n');f.close();exec(compile(code,__file__,'exec'))" build_ext -IC:\vcpkg\packages\openexr_x86-windows\include\OpenEXR -LC:\vcpkg\packages\openexr_x86-windows\lib install --record C:\Users\alexa\AppData\Local\Temp\pip-record-gjbp0u64\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\alexa\PycharmProjects\Test\venv\include\site\python3.8\openexr:
running build_ext
building 'OpenEXR' extension
creating build
creating build\temp.win32-3.8
creating build\temp.win32-3.8\Release
C:\Program Files (x86)\microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/OpenEXR -I/usr/local/include/OpenEXR -I/opt/local/include/OpenEXR -IC:\vcpkg\packages\openexr_x86-windows\include\OpenEXR -IC:\Users\alexa\PycharmProjects\Test\venv\include -IC:\Users\alexa\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\alexa\AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /TpOpenEXR.cpp /Fobuild\temp.win32-3.8\Release\OpenEXR.obj -g -DVERSION="1.3.2"
cl : Command line warning D9002 : ignoring unknown option '-g'
OpenEXR.cpp
OpenEXR.cpp(1011): warning C4244: 'argument': conversion from 'double' to 'const T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1025): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1024): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1027): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1026): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1035): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1082): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1081): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1084): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1083): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1086): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1085): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1088): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1087): warning C4244: 'argument': conversion from 'double' to 'T',possible loss of data
with
[
T=float
]
OpenEXR.cpp(1241): error C2143: syntax error: missing ')' before 'constant'
OpenEXR.cpp(1241): error C2664: 'PyObject *PyBytes_FromString(const char *)': cannot convert argument 1 from 'double' to 'const char *'
OpenEXR.cpp(1241): error C2660: 'PyDict_SetItemString': function does not take 2 arguments
C:\Users\alexa\AppData\Local\Programs\Python\Python38-32\include\dictobject.h(58): note: see declaration of 'PyDict_SetItemString'
OpenEXR.cpp(1241): error C2143: syntax error: missing ';' before 'constant'
OpenEXR.cpp(1241): error C2059: syntax error: ')'
error: command 'C:\\Program Files (x86)\\microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
编辑
您可以在https://www.lfd.uci.edu/~gohlke/pythonlibs/上找到针对python 3和2的OpenEXR绑定的二进制文件。无论如何,为了点子,如果有人知道如何调整点子完成的编译过程以使其起作用,请分享..