[跪求大牛] 这个错误如何解?No module named elementtree.ElementTree

wangnijie8634 2012-05-04 11:07:20
我们这边有段python,但是我对python一窍不通, 我发现错误是因为:
<type 'exceptions.ImportError'> : No module named elementtree.ElementTree

所以我在想,是不是因为没有安装elementtree这个模块
$ python
'import site' failed; use -v for traceback
Python 2.5.4 (r254:67916, May 14 2009, 10:42:44)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import elementtree.ElementTree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named elementtree.ElementTree

所以我就安装了这个模块

$ gzip -d elementtree-1.2.6-20050316.tar.gz && tar xvf elementtree-1.2.6-20050316.tar
$ cd elementtree-1.2.6-20050316
$ export PATH=/scratch/apple/python-2.5.4/bin:$PATH
$ export LD_LIBRARY_PATH=/scratch/apple/python-2.5.4/lib:$LD_LIBRARY_PATH
$ python setup.py install

从输出信息来看,是安装成功的


$ ls /scratch/apple/python-2.5.4/lib/python2.5/site-packages
elementtree elementtree-1.2.6_20050316-py2.5.egg-info README


但是还是import失败,而且我那程序也还是那个错误:

$ python
'import site' failed; use -v for traceback
Python 2.5.4 (r254:67916, May 14 2009, 10:42:44)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import elementtree.ElementTree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named elementtree.ElementTree
...全文
759 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangnijie8634 2012-05-04
  • 打赏
  • 举报
回复
我发现问题在哪了?但我不知道问题的根源在哪?
我的case好像把环境搞乱了,搞得每次运行python时,都会出一个错误提示"'import site' failed; use -v for traceback"

我如果重开一个窗口,就没有这问题了


大家知道,这是为什么吗?

wangnijie8634 2012-05-04
  • 打赏
  • 举报
回复
我试了

>>> import xml.etree.ElementTree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xml.etree.ElementTree

也不行
wangnijie8634 2012-05-04
  • 打赏
  • 举报
回复
$ cat README
This directory exists so that 3rd party packages can be installed
here. Read the source for site.py for more details.

$ pwd
/scratch/apple/python-2.5.4/lib/python2.5/site-packages

没发现有site.py啊
angel_su 2012-05-04
  • 打赏
  • 举报
回复
养成查看手册的习惯:
Python Library Reference: 8.13 xml.etree.ElementTree

装第三方模块也也行,一样先查查包里有没有文档,起码readme,install看一下
wangnijie8634 2012-05-04
  • 打赏
  • 举报
回复
有人知道是这怎么回事吗?
ch19860304 2012-05-04
  • 打赏
  • 举报
回复
http://www.velocityreviews.com/forums/t321378-re-import-error.html

查看环境变量PATH跟LD_LIBRARY_PATH的值,python不一致,乱了

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧