2

Using Ubuntu 14.04 following this lxml xpath tutorial https://www.youtube.com/watch?v=PgWfF-Ut0zM

Updated with this to download pip's upstream version of lxml https://stackoverflow.com/a/33089634

sudo apt-get install python-pip
pip install -U lxml
python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> page = open('/root/page1.html').read()
>>> from lxml import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name etree
Community
  • 1
  • 1
komputes
  • 139
  • 2
  • 6
  • Do you have an `lxml.py` in the local directory or maybe some corrupted install somewhere in your PYTHONPATH? `print lxml.__file__` and see if its the lxml you think it is. It should be `'/usr/lib/python2.7/dist-packages/lxml/__init__.pyc'` – tdelaney Nov 30 '15 at 19:37
  • 1
    ...or maybe `site-packages` – tdelaney Nov 30 '15 at 19:38
  • Neither of these apply to me. What seems to work is `easy_install lxml` – komputes Dec 09 '15 at 04:09

1 Answers1

4

Installing another version of lxml solved my issue:

pip install lxml==3.6.0
YJLO
  • 81
  • 4