2016-12-14 20 views
-1

源代碼:導入錯誤金字塔Hello World程序

from wsgiref.simple_server import make_server 
from pyramid.config import Configurator 
from pyramid.response import Response 

def hello_world(request): 
    return Response('<h1>Hello world!</h1>') 

if __name__ == '__main__': 
    config = Configurator() 
    config.add_view(hello_world) 
    app = config.make_wsgi_app() 
    server = make_server('0.0.0.0', 8080, app) 
    server.serve_forever() 

當我運行使用金字塔樣本程序hello_world程序中,我得到了下面的錯誤。

Traceback (most recent call last): 
    File "application.py", line 2, in <module> 
    from pyramid.config import Configurator 
    File "/usr/local/lib/python2.7/dist-packages/pyramid/config/__init__.py", line 12, in <module> 
    from pyramid.interfaces import (
    File "/usr/local/lib/python2.7/dist-packages/pyramid/interfaces.py", line 3, in <module> 
    from zope.interface import (
ImportError: No module named interface 
+0

請告訴我們源代碼.. – intelis

+0

@intelis添加源代碼 –

+0

我投票結束這個問題作爲題外話,因爲它是用戶的配置錯誤。 –

回答

0

您已經安裝了不正確的東西 - 用python setup.py develop,而不是某個地方的使用pip install -e .更可能。如果你混合使用工具,你會遇到一些問題。這個特定的一個似乎是由於名稱空間包未正確配置,這幾乎總是在同一環境中使用easy_install和pip的一個症狀。你需要選擇一個(最好是點),有時候決定使用哪一個已經由你安裝python的任何工具做出。

+0

配置正確。現在工作。謝謝 –