2011-06-11 128 views
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 

我應該到什麼地方弄清楚什麼是錯的?

+0

1.您的腳本是否擺弄着'sys.path'? 2.'env |的輸出是什麼? grep PYTHON'? 3.'import unittest'是否在交互式解釋器中工作? – 2011-06-11 22:10:38

+0

1.沒有2. PYTHONHOME =/home/shift/experiments/lib 3.編號 – Geo 2011-06-11 22:12:16

+0

也許是一個愚蠢的問題,但是你的.py文件中沒有一些假單詞在「unittest」之後?它是否從空閒或剛剛啓動pyton並輸入「import unittest」時工作? – 2011-06-11 22:14:17

回答

1

你有你的python環境安裝到/home/shift/experiments/lib?請參閱docs.python.org PYTHONHOME

+0

不,它以某種方式設置了這個價值,從那裏開始,所有的地獄都破滅了。 – Geo 2011-06-11 22:46:36

相關問題