backports/lzma/_lzmamodule.c(115) : 致命错误 C1083: 无法打开包含文件:“lzma.h”: 没有此文件或目录

backports/lzma/_lzmamodule.c(115) : 致命错误 C1083: 无法打开包含文件:“lzma.h”: 没有此文件或目录

我有一台安装了 Visual Studio 2015 upgrade 3 的 Windows 7 PC,我想使用 pip 为 Python 安装 backports.lzma 库。

我已经下载并解压了 Program Files 文件夹中的 XZ Utils。(XZ Utils 是安装 backports 库所必需的,如Pypi 网站

这是 pip 输出:

Installing collected packages: backports.lzma
Running setup.py install for backports.lzma: started
Running setup.py install for backports.lzma: finished with status 'error'
Complete output from command "C:\Program Files (x86)\Python27\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\myuser\\appdata\\local\\temp\\pip-build-smbn4k\\backports.lzma\\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\myuser\appdata\local\temp\pip-hfgg8w-record\install-record.txt --single-version-externally-managed --compile:
This is backports.lzma version 0.0.8
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
creating build\lib.win32-2.7\backports
copying backports\__init__.py -> build\lib.win32-2.7\backports
creating build\lib.win32-2.7\backports\lzma
copying backports\lzma\__init__.py -> build\lib.win32-2.7\backports\lzma
running build_ext
building 'backports/lzma/_lzma' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\backports
creating build\temp.win32-2.7\Release\backports\lzma
C:\Users\myuser\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG "-IC:\Program Files (x86)\Python27\include" -IC:\Users\myuser\include -I/opt/local/include -I/usr/local/include "-IC:\Program Files (x86)\Python27\include" "-IC:\Program Files (x86)\Python27\PC" /Tcbackports/lzma/_lzmamodule.c /Fobuild\temp.win32-2.7\Release\backports/lzma/_lzmamodule.obj
_lzmamodule.c
backports/lzma/_lzmamodule.c(32) : warning C4273: 'PyErr_NewExceptionWithDoc' : inconsistent dll linkage
        C:\Program Files (x86)\Python27\include\pyerrors.h(226) : see previous definition of 'PyErr_NewExceptionWithDoc'
backports/lzma/_lzmamodule.c(115) : fatal error C1083: Cannot open include file: 'lzma.h': No such file or directory
error: command 'C:\\Users\\myuser\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

----------------------------------------
Failed building wheel for backports.lzma
Command ""C:\Program Files (x86)\Python27\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\myuser\\appdata\\local\\temp\\pip-build-smbn4k\\backports.lzma\\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\myuser\appdata\local\temp\pip-hfgg8w-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\myuser\appdata\local\temp\pip-build-smbn4k\backports.lzma\
'backports.lzma' failed to install. Exit code: 1

Program Files\xz\include 里面有 lzma.h 文件,如何链接需要识别的头文件?

答案1

从以下位置下载适当的车轮文件 (.whl)https://www.lfd.uci.edu/~gohlke/pythonlibs/#backports.lzma

在python_2.7 windows_64_bit上安装,例如:

pip2.7 install c:\downloads\backports.lzma‑0.0.12‑cp27‑cp27m‑win_amd64.whl

引文

相关内容