运行示例金字塔程序时出现问题。给出导入错误:没有名为执行的模块错误
我是 python 和 Pyramid 的新手。 我今天安装了金字塔,并且我的 mac 机器上已经预装了 python 2.7.1。我已经按照官方网站中提到的说明安装了金字塔。我已将 virtualenv 与 nositepackages 一起使用,如网站中所述,并在我的 /users/sreekanth
目录中安装了金字塔。
安装后,我尝试了我的第一个示例程序,如所提到的 在文档中。
当我尝试运行该程序时,出现如下错误。
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
有人可以向我解释一下我缺少什么以及如何才能完成这项工作吗?
I am new to python and Pyramid.
I have installed pyramid today and i already have python 2.7.1 pre-installed on my mac machine. I have installed pyramid with the instructions mentioned in the official website. I have used the virtualenv with nositepackages as mentioned in the website and i installed pyramid in my /users/sreekanth
directory
After installing i tried my first sample program as mentioned in the docs.
When I try to run the program i am getting an error which is as below.
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
And also i am not able to import pyramid module from the python shell. Below is the error message i am getting.
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
Could someone kindly explain me what i am missing and how I can make this work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个错误表明您的程序中有拼写错误。最有可能的是,您编写
的是
因为您已将 pylons/pyramid 安装到 virtualenv 中,所以您需要首先在命令行中使用
source bin/activate
激活它。这将设置正确的 python 路径,您可以通过在 python 控制台中检查 sys.path 来检查该路径。The first error indicates you have a typo in your program. Most likely, you wrote
instead of
And since you've installed pylons/pyramid into a virtualenv, you need to activate it first, with
source bin/activate
in the command line. That will set the correct python path, which you can check by examiningsys.path
in a python console.