Re: [lxml] Why can't I import etree any more? It turns out I can!
It turns out that lxml does work with Python 3.5! In response to a question I had posted on StackOverflow, a commenter asked if I had actually tested this by running a Python script, or if I was merely relying on PyCharm's statement that it didn't know what etree is. I realized that I was relying on PyCharm, and should try actually using it. 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. RobR From: lxml [mailto:lxml-bounces@lxml.de] On Behalf Of Rob Richardson Sent: Monday, February 13, 2017 2:19 PM To: lxml@lxml.de Subject: [lxml] Why can't I import etree any more? I have found several instances of people asking this question but none of anyone answering it. In 32-bit Python 3.2, using lxml v3.2.3, I can import the etree class using this: from lxml import etree But in 64-bit Python 3.5, using the latest version of lxml acquired using "pip install lxml", the above statement fails because etree is an unknown reference. What happened? What do I have to do to use lxml's etree class now? Is there something else I need to do to install lxml for my Python 3.5 installation? I am running 64-bit Windows 7 SP 1. Thank you very much! Rob Richardson
participants (1)
-
Rob Richardson