2 shandalue shandalue 于 2014.11.16 17:24 提问

mac os下python导入libxml遇到的问题

我用pip安装了libxml2dom,但是import libxml2dom时提示:
shandow@mac:~ > python

Python 2.7.5 (default, Mar 9 2014, 22:15:05)

[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

import libxml2dom

Traceback (most recent call last):

File "", line 1, in

File "/Library/Python/2.7/site-packages/libxml2dom/__init__.py", line 24, in

from libxml2dom.macrolib import *

File "/Library/Python/2.7/site-packages/libxml2dom/macrolib/__init__.py", line 26, in

from libxml2dom.macrolib.macrolib import *

File "/Library/Python/2.7/site-packages/libxml2dom/macrolib/macrolib.py", line 30, in

from libxmlmods import libxml2mod

ImportError: No module named libxmlmods

按照错误提示,打开/Library/Python/2.7/site-packages/libxml2dom/macrolib/macrolib.py:
问题出在这里:

Try the conventional import first.

try:

import libxml2mod

except ImportError:

from libxmlmods import libxml2mod

首先导入libxml2mod,如果发生异常就从libxmlmods导入libxml2mod。我明明安装了libxml2mod,为什么导入不成功呢?接着尝试:sudo pip install libxmlmods,提示找不到。。。。。。求助大神帮忙解决

1个回答

oyljerry
oyljerry   Ds   Rxr 2014.12.26 21:06

libxml2mod 看来没有安装成功

Csdn user default icon
上传中...
上传图片
插入图片