Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.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 导入错误:没有名为testrunner的模块_Python_Plone_Importerror_Buildout - Fatal编程技术网

Python 导入错误:没有名为testrunner的模块

Python 导入错误:没有名为testrunner的模块,python,plone,importerror,buildout,Python,Plone,Importerror,Buildout,我随后将zc.recipe.testrunner添加到我的构建中。我可以成功运行buildout,但当我运行bin/test时,我得到: ImportError: No module named testrunner 我有zope.testrunner-4.0.4-py2.4.eggin /usr/local/lib/python2.4/site-packages 我也别住了 zope.testrunner = 4.0.4 zc.recipe.testruner = 1.4.0 zc.rec

我随后将
zc.recipe.testrunner
添加到我的构建中。我可以成功运行buildout,但当我运行
bin/test
时,我得到:

ImportError: No module named testrunner
我有
zope.testrunner-4.0.4-py2.4.egg
in

/usr/local/lib/python2.4/site-packages
我也别住了

zope.testrunner = 4.0.4
zc.recipe.testruner = 1.4.0
zc.recipe.egg = 1.3.2
当我运行buildout时,我使用了
-vvv
,得到了:

...
Installing 'zc.recipe.testrunner'.
We have the distribution that satisfies 'zc.recipe.testrunner==1.4.0'.
Egg from site-packages: z3c.recipe.scripts 1.0.1
Egg from site-packages: zope.testrunner 4.0.4
Egg from site-packages: zope.interface 3.8.0
Egg from site-packages: zope.exceptions 3.7.1
...
We have the distribution that satisfies 'zope.testrunner==4.0.4'.
Egg from site-packages: zope.testrunner 4.0.4
Adding required 'zope.interface'
 required by zope.testrunner 4.0.4.
We have a develop egg: zope.interface 0.0
Adding required 'zope.exceptions'
 required by zope.testrunner 4.0.4.
We have a develop egg: zope.exceptions 0.0
...
为什么我会害怕?zope.testrunner是否未正确安装

编辑:

[buildout]
...
parts =
    ...
    test

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs = 
    my.product
#!/usr/local/bin/python2.4 -S

import sys
sys.path[0:0] = [
    '/home/jil/mySandbox/myTrunk/parts/test/site-packages',
    ]


import os
path = sys.path[0]
if os.environ.get('PYTHONPATH'):
    path = os.pathsep.join([path, os.environ['PYTHONPATH']])
os.environ['BUILDOUT_ORIGINAL_PYTHONPATH'] = os.environ.get('PYTHONPATH', '')
os.environ['PYTHONPATH'] = path
import site # imports custom buildout-generated site.py
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
os.chdir('/home/jil/mySandbox/myTrunk/parts/test/working-directory')

import zope.testrunner

if __name__ == '__main__':
    zope.testrunner.run((['--auto-color', '--auto-progress']) + [
        '--test-path', '/home/jil/mySandbox/myTrunk/src/my.product',
        ])    
Traceback (most recent call last):
File "/home/jil/mySandbox/myTrunk/bin/test", line 20, in ?
  import zope.testrunner
ImportError: No module named testrunner
这是我的构建中的相关部分:

[buildout]
...
parts =
    ...
    test

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs = 
    my.product
#!/usr/local/bin/python2.4 -S

import sys
sys.path[0:0] = [
    '/home/jil/mySandbox/myTrunk/parts/test/site-packages',
    ]


import os
path = sys.path[0]
if os.environ.get('PYTHONPATH'):
    path = os.pathsep.join([path, os.environ['PYTHONPATH']])
os.environ['BUILDOUT_ORIGINAL_PYTHONPATH'] = os.environ.get('PYTHONPATH', '')
os.environ['PYTHONPATH'] = path
import site # imports custom buildout-generated site.py
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
os.chdir('/home/jil/mySandbox/myTrunk/parts/test/working-directory')

import zope.testrunner

if __name__ == '__main__':
    zope.testrunner.run((['--auto-color', '--auto-progress']) + [
        '--test-path', '/home/jil/mySandbox/myTrunk/src/my.product',
        ])    
Traceback (most recent call last):
File "/home/jil/mySandbox/myTrunk/bin/test", line 20, in ?
  import zope.testrunner
ImportError: No module named testrunner
这是
bin/test
中的内容:

[buildout]
...
parts =
    ...
    test

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs = 
    my.product
#!/usr/local/bin/python2.4 -S

import sys
sys.path[0:0] = [
    '/home/jil/mySandbox/myTrunk/parts/test/site-packages',
    ]


import os
path = sys.path[0]
if os.environ.get('PYTHONPATH'):
    path = os.pathsep.join([path, os.environ['PYTHONPATH']])
os.environ['BUILDOUT_ORIGINAL_PYTHONPATH'] = os.environ.get('PYTHONPATH', '')
os.environ['PYTHONPATH'] = path
import site # imports custom buildout-generated site.py
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
os.chdir('/home/jil/mySandbox/myTrunk/parts/test/working-directory')

import zope.testrunner

if __name__ == '__main__':
    zope.testrunner.run((['--auto-color', '--auto-progress']) + [
        '--test-path', '/home/jil/mySandbox/myTrunk/src/my.product',
        ])    
Traceback (most recent call last):
File "/home/jil/mySandbox/myTrunk/bin/test", line 20, in ?
  import zope.testrunner
ImportError: No module named testrunner
这是运行
bin/test
后出现的错误:

[buildout]
...
parts =
    ...
    test

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs = 
    my.product
#!/usr/local/bin/python2.4 -S

import sys
sys.path[0:0] = [
    '/home/jil/mySandbox/myTrunk/parts/test/site-packages',
    ]


import os
path = sys.path[0]
if os.environ.get('PYTHONPATH'):
    path = os.pathsep.join([path, os.environ['PYTHONPATH']])
os.environ['BUILDOUT_ORIGINAL_PYTHONPATH'] = os.environ.get('PYTHONPATH', '')
os.environ['PYTHONPATH'] = path
import site # imports custom buildout-generated site.py
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
os.chdir('/home/jil/mySandbox/myTrunk/parts/test/working-directory')

import zope.testrunner

if __name__ == '__main__':
    zope.testrunner.run((['--auto-color', '--auto-progress']) + [
        '--test-path', '/home/jil/mySandbox/myTrunk/src/my.product',
        ])    
Traceback (most recent call last):
File "/home/jil/mySandbox/myTrunk/bin/test", line 20, in ?
  import zope.testrunner
ImportError: No module named testrunner

我也有同样的问题。至少在我的例子中,原因是混合了“站点包”中已安装的依赖项和“鸡蛋”中由buildout安装的依赖项:zope.deprecation和zope.interface已经在我的“站点包”目录中,因此buildout没有重新安装。“bin/test”可执行文件上的路径操作似乎从“site packages”导入了“zope”包,而没有“testrunner”子包


尝试从“site packages”中删除所有zope.*包并重新运行buildout,或在buildout.cfg的“[buildout]”部分使用“include site packages=false”。第一个解决方案对我有效。

向我们展示构建的测试部分的配置,以及生成的bin/test脚本的内容。并且,可能是生成的bin/test脚本的完整回溯无效。可能testrunner只与Python2.6+Plone 4兼容?@Mikkoohtama我使用的是Plone3/Python2.4。它说zc.recipe.testrunner与Plone 4、Plone 3和Plone 2.5.x兼容。此外,zc.recipe.testrunner依赖于zope.testrunner(它依赖于zope.interface和zope.exceptions)。永远不要提及删除Python2.4支持。在任何情况下,您的bin/test脚本的sys.path中都没有任何鸡蛋,因此它可能无法工作。这个答案很有帮助,谢谢。不需要
包含站点包
,只需要创建一个新的virtualenv并只在其中安装buildout,就行了。