[英]Install lxml on ubuntu 13.04 for python 3.3 Eclipse
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: 当我尝试导入时,Eclipse仍然无法识别它:
from lxml import etree
Please help. 请帮忙。
Update your PYTHONPATH
in Eclipse, go to Preferences > PyDev > Interpreters - Python
Then update your paths to lxml
package. 在Eclipse中更新您的
PYTHONPATH
,转到Preferences > PyDev > Interpreters - Python
然后将您的路径更新为lxml
包。 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
我建议您重新加载解释器(首先将其删除,然后再次添加),它将加载所有程序包,而PyDev将识别
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? 您确定在尝试导入并成功执行脚本时该脚本是否正在使用Python 2.x解释器运行,或者是否正在使用Python 3.x解释器? I suspect that
python-lxml
is only installing a Python 2.x version of lxml
. 我怀疑
python-lxml
只是安装的一个Python 2.x版lxml
。 Try python3-lxml
. 试试
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). 另外,如果您希望使用
pip
进行安装,则您对lxml
的错误的pip
安装指出缺少pyconfig.h
文件,可以通过sudo apt-get install python3-dev
解决此问题(请注意,它是python3-dev
不是 python-dev
,它仅安装Python 2.x所需的dev文件。
Try adding lxml to the Forced Builtins found within Preferences: PyDev -> Interpreters -> Python Interpreter, then select the Forced Builtin tab. 尝试将lxml添加到“首选项”中的“强制内置”:PyDev->解释器-> Python解释器,然后选择“ 强制内置”选项卡。 It fixed it for me.
它为我解决了。
http://pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins http://pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.