0
似乎很奇怪,std Python lib中的某个模块会丢失。我可能做错了什么,但我无法弄清楚究竟是什么。Python:没有名为unittest的模块。我怎样才能解决这个问题?
[email protected]:~/experiments/$ python test/test_creation.py
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "test/test_creation.py", line 1, in <module>
import unittest
ImportError: No module named unittest
与-v开关运行表明这一点:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "test/test_creation.py", line 1, in <module>
import unittest
ImportError: No module named unittest
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] signal
# cleanup[1] exceptions
# cleanup[1] _warnings
# cleanup sys
# cleanup __builtin__
# cleanup ints: 3 unfreed ints
# cleanup floats
我应该到什么地方弄清楚什么是错的?
1.您的脚本是否摆弄着'sys.path'? 2.'env |的输出是什么? grep PYTHON'? 3.'import unittest'是否在交互式解释器中工作? – 2011-06-11 22:10:38
1.没有2. PYTHONHOME =/home/shift/experiments/lib 3.编号 – Geo 2011-06-11 22:12:16
也许是一个愚蠢的问题,但是你的.py文件中没有一些假单词在“unittest”之后?它是否从空闲或刚刚启动pyton并输入“import unittest”时工作? – 2011-06-11 22:14:17