相关疑难解决方法(0)

在python中安装lxml模块

在运行python脚本时,我遇到了这个错误

  from lxml import etree
ImportError: No module named lxml
Run Code Online (Sandbox Code Playgroud)

现在我尝试安装lxml

sudo easy_install lmxl
Run Code Online (Sandbox Code Playgroud)

但它给了我以下错误

Building lxml version 2.3.beta1.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' needs to be available.
ERROR: /bin/sh: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **
Run Code Online (Sandbox Code Playgroud)

使用libxslt的构建配置

src/lxml/lxml.etree.c:4: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

python lxml python-import

79
推荐指数
6
解决办法
16万
查看次数

将lxml.etree导入python时出错

我在我的mac上安装了一个lxml,当我输入这样的python时

localhost:lxml-3.0.1 apple$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
  File "", line 1, in 
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.0.1-py2.7-macosx-10.6-intel.egg/lxml/etree.so, 2): Symbol not found: ___xmlStructuredErrorContext
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.0.1-py2.7-macosx-10.6-intel.egg/lxml/etree.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-3.0.1-py2.7-macosx-10.6-intel.egg/lxml/etree.so

python lxml python-2.7

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

lxml ×2

python ×2

python-2.7 ×1

python-import ×1