Python:没有名为unittest的模块。我怎样才能解决这个问题?

时间:2011-06-11 22:07:29

标签: python unit-testing

从std Python lib中删除一个模块似乎很奇怪。我可能做错了什么,但我无法弄明白到底是什么。

shift@bt:~/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 个答案:

答案 0 :(得分:1)

您的python环境是否已安装到/home/shift/experiments/lib?请参阅PYTHONHOME

上的docs.python.org