簡體   English   中英

Python:沒有名為 unittest 的模塊。 我怎樣才能解決這個問題?

[英]Python: no module named unittest. How can I fix this?

缺少來自 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

我應該去哪里找出問題所在?

您已將 python 環境安裝到/home/shift/experiments/lib嗎? 請參閱 PYTHONHOME 上的docs.python.org

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM