Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

backports/lzma/_lzmamodule.c(115) : fatal error C1083: Cannot open include file: 'lzma.h': No such file or directory #22

Closed
cirmic opened this issue May 25, 2017 · 8 comments

Comments

@cirmic
Copy link

cirmic commented May 25, 2017

I have a Windows 7 PC with Visual Studio 2015 upgrade 3 installed on it and I would like to install backports.lzma library for Python with pip.

I have downloaded and extracted XZ Utils in Program Files folder. (XZ Utils is mandatory for install backports library as specified from Pypi site )

This is the pip output:

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

However in Program Files\xz\include there is the lzma.h file.
How to link the header to be recognized?

@peterjc
Copy link
Owner

peterjc commented May 25, 2017

I do not currently have access to a Windows development machine to try this on.

However, in somewhat lucky timing, yesterday and today I have been experimenting with AppVeyor, and while I'm currently stuck I know how to solve the current issue.

By default the setup.py will look for lzma.h under $HOME/include/lzma.h so the simple answer is put this under your home folder rather than under "Program Files". Since there are no explicit recommendations on where to unzip that folder, this is a sensible option you'll certainly have write permissions here.

Assuming you didn't compile liblzma yourself, you will likely also need to move the DLLs from the platform specific files to $HOME/lib/ instead, i.e. for 32-bit:

cp C:/Users/YOURNAME/bin_i686/liblzma.* C:/Users/YOURNAME/lib/"

Or for 64 bit:

cp C:/Users/YOURNAME/bin_x86-64/liblzma.* C:/Users/YOURNAME/lib/"

At this point I began to run into trouble with linking, and am currently stuck.

See https://ci.appveyor.com/project/peterjc/backports-lzma/build/ and my AppVeyor configuration file on this branch https://github.com/peterjc/backports.lzma/blob/appveyor/.appveyor.yml

Over on #14 it was reported that backports.lzma could be compiled on Windows using a self-compiled liblzma.

@jakirkham
Copy link
Contributor

There is an AppVeyor build proposed in PR ( #25 ).

@fireattack
Copy link

fireattack commented May 15, 2018

This is still an issue. I tried to place lzma.h to $HOME/include/ (C:\users\[username]\include), but now it starts to show another error:

LINK : fatal error LNK1181: cannot open input file 'liblzma.lib'

I have no idea where to get this liblzma.lib, but I guess that's what you mentioned before about 'trouble with linking'.

Is there any other way to install it on Windows? The wheel version in #14 (0.0.3) seems to work, but very outdated.

@peterjc
Copy link
Owner

peterjc commented May 16, 2018

You can use conda, the conda-forge packages include Windows builds and cover Python 2.7, 3.5 and 3.6 at the time of writing: https://anaconda.org/conda-forge/backports.lzma

@cgohlke
Copy link

cgohlke commented May 16, 2018

Is there any other way to install it on Windows? The wheel version in #14 (0.0.3) seems to work, but very outdated.

Up-to-date wheels for Python 2.7, 3.4, 3.5, 3.6, and 3.7 are at https://www.lfd.uci.edu/~gohlke/pythonlibs/#backports.lzma

@fireattack
Copy link

Thank you!

@peterjc
Copy link
Owner

peterjc commented May 16, 2018

I think I've said this in other contexts, but once again, thank you @cgohlke for your efforts supporting Python on Windows 🥇

If you have no objection, I would be happy to add a link to these wheels from the README file

@peterjc
Copy link
Owner

peterjc commented Dec 14, 2021

I'm about to archive this repository, and so am closing the outstanding issues and pull requests. Thank you for your efforts though.

@peterjc peterjc closed this as completed Dec 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants