[跪求大牛] 这个错误如何解?No module named elementtree.ElementTree
我们这边有段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
[解决办法]
http://www.velocityreviews.com/forums/t321378-re-import-error.html
查看环境变量PATH跟LD_LIBRARY_PATH的值,python不一致,乱了