I want to use xpath in python . I tried
import xml.etree.ElementTree as ET
Since this library has limited usage I had to use lxml after a long session of search on google. I had several problems during installation and finally i installed lxml but when i use
from lxml import etree
it throws back an error as below. could you please tell me the solution to this problem!!!
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from lxml import etree
ImportError: DLL load failed: %1 is not a valid Win32 application.
Can any1 tell me what the problem would be?? Thanks for assistance!!
lxml is a Python library which allows for easy handling of XML and HTML files, and can also be used for web scraping. There are a lot of off-the-shelf XML parsers out there, but for better results, developers sometimes prefer to write their own XML and HTML parsers.
The latest version is lxml 4.9. 1, released 2022-07-01 (changes for 4.9. 1). Older versions are listed below.
Type “ pip install lxml ” (without quotes) in the command line and hit Enter again. This installs lxml for your default Python installation. The previous command may not work if you have both Python versions 2 and 3 on your computer. In this case, try "pip3 install lxml" or “ python -m pip install lxml “.
I know that's late to say this... But may help someone someday..
I use the following code to solve the exact same problem here
python -m pip uninstall lxml
python -m pip install lxml==3.6.0
I solved this by downloading the 64-bit version of lxml here:
https://pypi.python.org/pypi/lxml/3.4.1
lxml-3.4.1.win-amd64-py2.7.exe
It's the only one that worked to solve the win32 error. You might want to destroy the old version of lxml before you do this.
Since you mentioned you had to fight with lxml to get it to install, it's hard to say where in that process this error might've cropped up.
Are you installing lxml to your default installation of Python or somewhere else? If you're installing to your default installation, one of the .exe options from https://pypi.python.org/pypi/lxml/3.2.0 might be your best bet. I, too, have had to fight with lxml in some cases but those .exe options are the easiest way I've found.
If you are trying to install lxml to some other Python installation, I'd suggest using a .egg file along with setup tools. Sadly, the most recent .egg files I can find for lxml are for 2.3 but you can get them here https://botbot.me/freenode/kivy/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With