I have tried all of the following:
apt-get install python-lxml
apt-get install libxml2-dev libxslt1-dev
pip install lxml (gives me a compile error, no pyconfig.h)
easy_install lxml
Eclipse still does not recognize it when I try to import:
from lxml import etree
Please help.
Update your PYTHONPATH
in Eclipse, go to Preferences > PyDev > Interpreters - Python
Then update your paths to lxml
package. I suggest you to reload your interpreter (first delete it, and next add it again) it will load all packages and PyDev will recognized lxml
Are you sure your script when you tried importing and were successful is running with the Python 2.x interpreter or whether it's using the Python 3.x interpreter? I suspect that python-lxml
is only installing a Python 2.x version of lxml
. Try python3-lxml
.
Alternatively, if you wish to install using pip
, your pip
install of lxml
's error points to the lack of a pyconfig.h
file which can be solved by sudo apt-get install python3-dev
in your case (note that it's the python3-dev
not python-dev
, which only installs the required dev files for Python 2.x).
Try adding lxml to the Forced Builtins found within Preferences: PyDev -> Interpreters -> Python Interpreter, then select the Forced Builtin tab. It fixed it for me.
http://pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.