ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

'lxml' dependency is broken on Windows

Open superswan opened this issue 2 years ago • 2 comments

Attempting to install latest version gives an error when installing the lxml dependency on Windows 11

Attempted to install lxml NuGet package in Visual Studio but still can't build this package. There is no wheel package for Windows Python 3.11

PS Z:\Programming\chatGPT\Playground> pip3 install revChatGPT --upgrade
Requirement already satisfied: revChatGPT in c:\python311\lib\site-packages (0.0.14)
Collecting revChatGPT
  Downloading revChatGPT-0.0.23.5-py3-none-any.whl (14 kB)
Collecting bs4
  Downloading bs4-0.0.1.tar.gz (1.1 kB)
  Preparing metadata (setup.py) ... done
Collecting lxml
  Downloading lxml-4.9.1.tar.gz (3.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 54.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
. . .
Installing collected packages: tls-client, soupsieve, lxml, beautifulsoup4, bs4, revChatGPT
  DEPRECATION: lxml is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for lxml ... error
  error: subprocess-exited-with-error

  × Running setup.py install for lxml did not run successfully.
  │ exit code: 1
  ╰─> [96 lines of output]
      Building lxml version 4.9.1.
      Building without Cython.
      Building against pre-built libxml2 andl libxslt libraries
      running install
      C:\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
. . .
      "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc\lxml\includes -IC:\Python311\include -IC:\Python311\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcsrc\lxml\etree.c /Fobuild\temp.win-amd64-cpython-311\Release\src\lxml\etree.obj -w
      cl : Command line warning D9025 : overriding '/W3' with '/w'
      etree.c
      C:\Users\user\AppData\Local\Temp\pip-install-rh5v03nk\lxml_23167b2f100d4470a19a380bfa8a641e\src\lxml\includes/etree_defs.h(14): fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
      Compile failed: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
ocal\Temp\xmlXPathInitjtxtwcqk.c(1): fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
      error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      *********************************************************************************
      Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
      *********************************************************************************
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lxml

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

superswan avatar Dec 06 '22 01:12 superswan

Thank you for the report. Now that this has been confirmed, I will work towards removing bs4 and lxml from the repo. In the meantime,

If you encounter an error about installing lxml, download the required lxml library from "https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml" and then run the following command:

For Python3.10: `pip install lxml‑4.9.0‑cp310‑cp310‑win_amd64.whl`
For Python3.11: `pip install lxml-4.9.0-cp311-cp311-win_amd64.whl`

This will install the library and allow the program to run properly.

acheong08 avatar Dec 06 '22 01:12 acheong08

Fixed, Thank you.

superswan avatar Dec 06 '22 03:12 superswan

Currently unable to test but will setting BeautifulSoup parser to "html.parser" remove lxml dependency? I understand why it is the preferred parser but the external C dependency may make the script less portable.

superswan avatar Dec 06 '22 18:12 superswan

I just opened a PR that fully removes bs4. #103

bird avatar Dec 06 '22 20:12 bird

I just merged it to main. Can you test it out by cloning the repo and pip3 install . within the directory?

acheong08 avatar Dec 07 '22 01:12 acheong08

Please help me with that, I am trying to install the package manually but no file can be compatible with my version

image

abdelrhmaaan avatar Mar 27 '23 00:03 abdelrhmaaan

New versions don't use lxml anymore

acheong08 avatar Mar 27 '23 08:03 acheong08

should I install an older version then ?? I need it for web scraping

abdelrhmaaan avatar Mar 27 '23 11:03 abdelrhmaaan