Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:没有名为unittest的模块。我怎样才能解决这个问题?_Python_Unit Testing - Fatal编程技术网

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

Python:没有名为unittest的模块。我怎样才能解决这个问题?,python,unit-testing,Python,Unit Testing,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

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
shift@bt:~/experiments/$python test/test\u creation.py
“导入站点”失败;使用-v进行回溯
回溯(最近一次呼叫最后一次):
文件“test/test_creation.py”,第1行,在
导入单元测试
ImportError:没有名为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 2.6.5(r265:79063,2010年4月16日,13:09:56) [GCC 4.4.3]关于linux2 有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。 回溯(最近一次呼叫最后一次): 文件“test/test_creation.py”,第1行,在 导入单元测试 ImportError:没有名为unittest的模块 #清除内置的_ #清除系统路径 #清除系统argv #清除系统ps1 #清除sys.ps2 #清除sys.exitfunc #清除系统exc_类型 #清除系统exc_值 #清除sys.exc\u回溯 #清除系统最后一个类型 #清除系统最后一个值 #清除系统上次追踪 #清除系统路径挂钩 #清除sys.path\u导入器\u缓存 #清除sys.meta_路径 #清除系统标志 #清除系统浮动信息 #还原sys.stdin #还原系统stdout #还原sys.stderr #清理主管道__ #清理[1]zipimport #清除[1]信号 #清理[1]异常 #清理[1]\u警告 #清理系统 #清除内置__ #清除整数:3个未清除整数 #清理浮动
我应该从哪里找出问题所在?

您已经将python环境安装到
/home/shift/experiments/lib
中了吗?请参阅

上的docs.python.org您的python环境已安装到
/home/shift/experiments/lib
?请参见

1上的docs.python.org。您的脚本是否会摆弄
sys.path
?2.
env|grep PYTHON
的输出是什么?3.
import unittest
是否在交互式解释器中工作。二号。PYTHONHOME=/home/shift/experiments/lib3。不,也许是个愚蠢的问题,但在“unittest”之后,你的.py文件中没有虚假字符吗?它是在空闲状态下工作还是在启动pyton并键入“importunittest”时工作?检查PYTHONHOME的设置位置,ops没有看到注释。好了,现在你知道去哪里找了。那个env把事情搞砸了:)@Fredrik,交互口译员也不能用@ashwoods,我的PYTHONHOME设置为/home/shift/experiments/lib,与测试文件夹位于同一文件夹中,尽管我没有手动设置。1。您的脚本是否会摆弄
sys.path
?2.
env|grep PYTHON
的输出是什么?3.
import unittest
是否在交互式解释器中工作。二号。PYTHONHOME=/home/shift/experiments/lib3。不,也许是个愚蠢的问题,但在“unittest”之后,你的.py文件中没有虚假字符吗?它是在空闲状态下工作还是在启动pyton并键入“importunittest”时工作?检查PYTHONHOME的设置位置,ops没有看到注释。好了,现在你知道去哪里找了。那个env把事情搞砸了:)@Fredrik,交互口译员也不能用@ashwoods,我的PYTHONHOME被设置为/home/shift/experiments/lib,与测试文件夹在同一个文件夹中,虽然我没有手动设置。不,它不知怎么地被设置为那个值,从那以后,一切都乱套了。不,它不知怎么地被设置为那个值,从那以后,一切都乱套了。