Python 没有名为';zope.反对';使用简单的hello world金字塔应用程序

Python 没有名为';zope.反对';使用简单的hello world金字塔应用程序,python,amazon-web-services,pyramid,Python,Amazon Web Services,Pyramid,我正在尝试学习如何将金字塔应用程序部署到AWS(Elastic Beanstalk),我正在一步一步地进行,但我被卡住了。我使用是为了保持简单,但我得到了以下错误,我不知道为什么: [Mon Feb 20 18:08:33.477650 2017] [:error] [] mod_wsgi (pid=2811): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python modul

我正在尝试学习如何将金字塔应用程序部署到AWS(Elastic Beanstalk),我正在一步一步地进行,但我被卡住了。我使用是为了保持简单,但我得到了以下错误,我不知道为什么:

[Mon Feb 20 18:08:33.477650 2017] [:error] [] mod_wsgi (pid=2811): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
[Mon Feb 20 18:08:33.477918 2017] [:error] [] mod_wsgi (pid=2811): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Mon Feb 20 18:08:33.478124 2017] [:error] [] [remote 69.127.251.49:45648] Traceback (most recent call last):
[Mon Feb 20 18:08:33.478329 2017] [:error] []   File "/opt/python/current/app/application.py", line 2, in <module>
[Mon Feb 20 18:08:33.478440 2017] [:error] []     from pyramid.config import Configurator
[Mon Feb 20 18:08:33.478630 2017] [:error] []   File "/opt/python/run/venv/lib/python3.4/site-packages/pyramid/config/__init__.py", line 12, in <module>
[Mon Feb 20 18:08:33.478745 2017] [:error] []     from pyramid.interfaces import (
[Mon Feb 20 18:08:33.478923 2017] [:error] []   File "/opt/python/run/venv/lib/python3.4/site-packages/pyramid/interfaces.py", line 1, in <module>
[Mon Feb 20 18:08:33.479050 2017] [:error] []     from zope.deprecation import deprecated
[Mon Feb 20 18:08:33.479213 2017] [:error] [] ImportError: No module named 'zope.deprecation'
我已采取的步骤:

SSH’ed到实例中,并通过

sudo/opt/python/run/venv/bin/pip安装金字塔

已检查pip冻结,且其存在且处于正确的venv中

(venv)[ec2-user@ ~]$ pip list
hupper (0.4.2)
PasteDeploy (1.5.2)
pip (7.1.2)
pyramid (1.8.2)
repoze.lru (0.6)
setuptools (18.4)
translationstring (1.3)
venusian (1.0)
WebOb (1.7.1)
zope.deprecation (4.2.0)
zope.interface (4.3.3)

(venv)[ec2-user@ ~]$ pip --version
pip 7.1.2 from /opt/python/run/venv/local/lib/python3.4/site-packages(python 3.4)
我试图直接从python调用模块,但没有成功

(venv)[ec2-user@ ~]$ python
Python 3.4.3 (default, Sep  1 2016, 23:33:38) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from zope.deprecation import deprecation
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'zope.deprecation'
>>> 

我将尝试并希望添加一个更好的答案。

在将
setup.py
pip install
混合使用时,由于每个系统如何处理名称空间包(如
zope.XXX
),此类错误经常发生。解决方案通常是将所有东西吹走,然后只使用一个工具安装。例如,如果您现在正在使用
python setup.py develope
,请将其替换为
pip install-e。

我还没有理由,但快速回答是我需要使用zope.deprecation 4.1.2。版本4.2导致了一些问题。

Pyramid 1.8.2一天前发布,可能是一个bug。您是否尝试过使用较旧的稳定版本的Pyramid?。回滚到1.7,并将zope.deprecation回滚到4.1.2,但效果不佳。我还试着把它们放在requirements.txt文件中,然后推出一个新的应用程序。@webjunkie你是对的……有点。原来是zope.deprecation的版本造成的。它安装了4.2和金字塔1.8.1,并进行了轰炸。我安装了4.1.2和1.8.1。我仍然需要找出原因。我使用的是单文件python脚本,因此没有setup.py。我也很想尝试这种方法。如果是这样的话,那么我对我的回答就更加肯定了,因为这显然是某种安装问题。是的,肯定是安装问题,但我已经尝试了安装requirements.txt,并手动安装了zope.deprecation 4.1.2和pyramid 1.8.1(按此顺序),而且效果很好。不幸的是,调试4.2对我来说并不是一个关键问题,所以找出发生了什么事情在我的任务清单上是很低的。
(venv)[ec2-user@ ~]$ python
Python 3.4.3 (default, Sep  1 2016, 23:33:38) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from zope.deprecation import deprecation
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'zope.deprecation'
>>> 
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response


def hello_world(request):
    return Response('Hello %(name)s!' % request.matchdict)

config = Configurator()
config.add_route('hello', '/hello/{name}')
config.add_view(hello_world, route_name='hello')
application = config.make_wsgi_app()

if __name__ == '__main__':  
    server = make_server('', 8000, application)
    server.serve_forever()