I have used lxml's etree class successfully in 32-bit Python 3.2 using from lxml import etree
, but I just installed it for 64-bit Python 3.5 using pip install lxml
, and PyCharm calls etree an unresolved reference. PyCharm's interpreter settings window tells me that I am using version 3.2.3 of lxml in Python 3.2, and version 3.7.2 in Python 3.5.
I rely on XML parsing extensively in my scripts. How can I import etree from the latest version of lxml, or is there something else I'm supposed to do to get similar functionality from that module?
This question is a duplicate of one posted in April of 2016, but that question and similar ones were never answered. If I missed a question that had as answer, I would appreciate a link to that question.
Thank you very much.
EDIT: It appears that lxml does work with Python 3.5! After Dragon asked if I had actually tested it in Python or was merely relying on PyCharm flagging etree as unresolved, I tried I was merely relying on PyCharm. I tried this script:
from lxml import etree
if __name__=='__main__':
print ("This is a print statement.")
try:
x = etree.fromstring("This is not XML")
except Exception as ex:
print (str(ex))
The output of this was:
C:\Python35\python.exe C:/Misc/lxmltest.py
This is a print statement.
Start tag expected, '<' not found, line 1, column 1 (<string>, line 1)
Process finished with exit code 0
I was expecting an unresolved reference error. Instead, the error message shows that etree.fromstring() was successfully called.
Many thanks to Dragon for his (her?) help