Create a Distributed Package that uses lxml

187 views Asked by At

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.

1

There are 1 answers

0
Efrain Vergara On

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