0

I've created a python package that uses lxml.
In setup.py I have defined:

packages=find_packages(),  # Required
python_requires='>=3.8, <4',
install_requires=[
    'typer[all]',
    'packaging',
    'lxml'
]

Tests, packaging and deployments work just fine.
However, after uploading the package to my company's PyPi repository, I'm trying to install the package with:

pip install -i <mypypirepo> <mypackage>

I get the a long error including:

fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    *********************************************************************************
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python39\python.exe'

While trying to install manually the lxml I get the same exact error.

I found solutions on stackoverflow that talk about manually downloading a compatible wheel version of lxml and then installing it with pip.
However, the lxml is a part of the package that should be easily installed by the end-user.

Is there any way to solve the issue without forcing the user to manually install lxml?

Note: This issue only started happening after upgrading python from 3.8 to 3.9.

Alex Weitz
  • 3,199
  • 4
  • 34
  • 57
  • The issue is not related to pip. Some packages rely on system libraries, in this case it is `libxml2`. It is not the same as the PyPI package; lxml expects you to install the lbirary it manually. – Marat Oct 09 '20 at 05:29
  • Does this answer your question? [Getting "Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?" when installing lxml through pip](https://stackoverflow.com/questions/33785755/getting-could-not-find-function-xmlcheckversion-in-library-libxml2-is-libxml2) – AMC Oct 13 '20 at 00:40
  • @AMC No, it doesn't, since the answer given requires the user to literally go to a website, download something and manually install it – Alex Weitz Oct 13 '20 at 00:47
  • This might be useful: https://stackoverflow.com/q/3493151 – AMC Oct 13 '20 at 01:30

1 Answers1

0

As of this writing 2020-10-12 there is no lxml wheel for python 3.9 on PyPI.

If using windows like I do there are unofficial wheels here:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml