2011-12-27 68 views
-2

我是python和pyramid的新手。 今天我已經安裝了pyramid,我已經在我的mac機器上預安裝了python 2.7.1。我已經安裝了金字塔instructions mentioned in the official website。我已經使用網站上提到的nositepackages virtualenv,我在我的/users/sreekanth目錄中安裝金字塔運行示例金字塔程序時出現問題。給ImportError:沒有名爲execptions錯誤的模塊

安裝後,我試了我的第一個示例程序,如提到 in the docs

當我嘗試運行程序時,出現如下錯誤。

sreekanths-MacBook-Pro:tasks Sreekanth$ ../bin/python2.7 tasks.py 
Traceback (most recent call last): 
    File "tasks.py", line 87, in <module> 
    config.scan() 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/config/__init__.py", line 893, in scan 
    scanner.scan(package, categories=categories, onerror=onerror) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/venusian-1.0a2-py2.7.egg/venusian/__init__.py", line 95, in scan 
    invoke(name, ob) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/venusian-1.0a2-py2.7.egg/venusian/__init__.py", line 92, in invoke 
    callback(self, name, ob) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/view.py", line 210, in callback 
    config.add_view(view=ob, **settings) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/config/views.py", line 575, in wrapper 
    return wrapped(*arg, **defaults) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/config/util.py", line 59, in wrapper 
    result = wrapped(self, *arg, **kw) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/config/views.py", line 926, in add_view 
    context = self.maybe_dotted(context) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/config/__init__.py", line 808, in maybe_dotted 
    return self.name_resolver.maybe_resolve(dotted) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/path.py", line 318, in maybe_resolve 
    return self._resolve(dotted, package) 
    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/path.py", line 325, in _resolve 
    return self._zope_dottedname_style(dotted, package) 


    File "/Users/Sreekanth/env/lib/python2.7/site-packages/pyramid-1.3a3-py2.7.egg/pyramid/path.py", line 374, in _zope_dottedname_style 
    __import__(used) 
ImportError: No module named execptions 

而且我也無法從python shell導入金字塔模塊。以下是我收到的錯誤消息。

sreekanths-MacBook-Pro:bin Sreekanth$ pwd 
/Users/Sreekanth/env/bin 
sreekanths-MacBook-Pro:bin Sreekanth$ python 
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import pyramid 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named pyramid 

有人可以好心解釋我缺少什麼以及如何使這項工作。

回答

5

第一個錯誤表示您在程序中有錯字。最有可能的,你寫

from pyramid.execptions import NotFound 

,而不是

from pyramid.exceptions import NotFound 
#    ^^ 

既然你已經安裝掛架/金字塔到virtualenv中,你需要首先激活它,在命令行source bin/activate。這將設置正確的Python路徑,您可以通過在python控制檯中檢查sys.path來檢查該路徑。

相關問題