The lxml package for Python seems to absolutely broken on my system. I am not sure of the problem, as all of the files are in place, it seems. My suspicion is that the problem is in __init__.py, but I don’t have enough practice with the system to make an accurate diagnosis or fix the problem.
Here is some code that I think will help diagnose the problem:
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> dir(lxml)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> print lxml.__path__
['/usr/lib/python2.6/dist-packages/lxml']
>>> c = open("/usr/lib/python2.6/dist-packages/lxml/__init__.py", "r")
>>> for line in c:
... print line
...
# this is a package
>>> c.close()
>>> import os
>>> os.system("ls /usr/lib/python2.6/dist-packages/lxml/")
builder.py ElementInclude.py __init__.py sax.pyc
builder.pyc ElementInclude.pyc __init__.pyc usedoctest.py
cssselect.py _elementpath.py objectify.so usedoctest.pyc
cssselect.pyc _elementpath.pyc pyclasslookup.py
doctestcompare.py etree.so pyclasslookup.pyc
doctestcompare.pyc html sax.py
0
>>>
Like I said, my suspicion is that __init__.py contains the problem, but I’m not 100% sure.
Also, I’m using Linux Mint 8 – the rough equivalent of Ubuntu 9.10.
Thanks in advance.
No, you’re just doing it wrong! Try, e.g.,
from lxml import etree, and you should be able to useetreefully.import lxml— importing the package! — does not give you implicit access to any of the package’s modules!-)