Python:没有名为unittest的模块。我该怎么解决?

2024-04-26 05:21:07 发布

您现在位置:Python中文网/ 问答频道 /正文

std Python库中的模块丢失似乎很奇怪。我可能做错了什么,但我不知道到底是什么。

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

我应该到哪里去找出哪里不对劲?


Tags: pathpytestimportforsysrestoreunittest