python - Pyramid 网络框架 hello world 不工作

标签 python pyramid

我正在尝试运行 "hello world" application适用于 Pyramid Web 框架,但出现以下错误。有人可以告诉我我需要安装什么吗?谢谢

C:\Python27>python pyramid_hello.py
Traceback (most recent call last):
  File "pyramid_hello.py", line 2, in <module>
    from pyramid.config import Configurator
  File "C:\Python27\lib\site-packages\pyramid-1.5-py2.7.egg\pyramid\config\__init__.py", line 11, in <module>
    from pyramid.interfaces import (
  File "C:\Python27\lib\site-packages\pyramid-1.5-py2.7.egg\pyramid\interfaces.py", line 1, in <module>
    from zope.deprecation import deprecated
ImportError: No module named deprecation

C:\Python27>pip install zope
Downloading/unpacking zope
  Could not find any downloads that satisfy the requirement zope
No distributions at all found for zope
Storing complete log in C:\Users\Tracy\pip\pip.log

C:\Python27>pip install zope.deprecation
Requirement already satisfied (use --upgrade to upgrade): zope.deprecation in c:\python27\lib\site-packages\zope.deprecation-4.1.1-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): distribute in c:\python27\lib\site-packages\distribute-0.6.26-py2.7.egg (from zope.deprecation)
Cleaning up...

C:\Python27>pip install zope.deprecation --upgrade
Requirement already up-to-date: zope.deprecation in c:\python27\lib\site-packages\zope.deprecation-4.1.1-py2.7.egg
Downloading/unpacking distribute from https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a (from zope.deprecation)
  Downloading distribute-0.7.3.zip (145kB): 145kB downloaded
  Running setup.py egg_info for package distribute

Downloading/unpacking setuptools>=0.7 (from distribute->zope.deprecation)
  Downloading setuptools-3.4.4.tar.gz (794kB): 794kB downloaded
  Running setup.py egg_info for package setuptools

Installing collected packages: distribute, setuptools
  Found existing installation: distribute 0.6.26
    Uninstalling distribute:
      Successfully uninstalled distribute
  Running setup.py install for distribute

  Found existing installation: distribute 0.6.26
    Can't uninstall 'distribute'. No files were found to uninstall.
  Running setup.py install for setuptools

    Installing easy_install-script.py script to C:\Python27\Scripts
    Installing easy_install.exe script to C:\Python27\Scripts
    Installing easy_install.exe.manifest script to C:\Python27\Scripts
    Installing easy_install-2.7-script.py script to C:\Python27\Scripts
    Installing easy_install-2.7.exe script to C:\Python27\Scripts
    Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts
Successfully installed distribute setuptools
Cleaning up...

C:\Python27>python pyramid_hello.py
Traceback (most recent call last):
  File "pyramid_hello.py", line 2, in <module>
    from pyramid.config import Configurator
  File "C:\Python27\lib\site-packages\pyramid-1.5-py2.7.egg\pyramid\config\__init__.py", line 11, in <module>
    from pyramid.interfaces import (
  File "C:\Python27\lib\site-packages\pyramid-1.5-py2.7.egg\pyramid\interfaces.py", line 1, in <module>
    from zope.deprecation import deprecated
ImportError: No module named deprecation

C:\Python27>pip install deprecation
Downloading/unpacking deprecation
  Could not find any downloads that satisfy the requirement deprecation
No distributions at all found for deprecation
Storing complete log in C:\Users\Tracy\pip\pip.log

使用虚拟环境:

C:\Python27>easy_install virtualenv
Searching for virtualenv
Reading https://pypi.python.org/simple/virtualenv/
Best match: virtualenv 1.11.4
Downloading https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.11.4.tar.gz#md5=9accc2d3f0ec1da479ce2c3d1fdff06e
Processing virtualenv-1.11.4.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-o3mttl\virtualenv-1.11.4\setup.cfg
Running virtualenv-1.11.4\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-o3mttl\virtualenv-1.11.4\egg-dist-tmp-qi3l26
warning: no previously-included files matching '*' found under directory 'docs\_templates'
warning: no previously-included files matching '*' found under directory 'docs\_build'
Adding virtualenv 1.11.4 to easy-install.pth file
Installing virtualenv-script.py script to C:\Python27\Scripts
Installing virtualenv.exe script to C:\Python27\Scripts
Installing virtualenv.exe.manifest script to C:\Python27\Scripts
Installing virtualenv-2.7-script.py script to C:\Python27\Scripts
Installing virtualenv-2.7.exe script to C:\Python27\Scripts
Installing virtualenv-2.7.exe.manifest script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\virtualenv-1.11.4-py2.7.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

C:\Python27>set VENV=c:\env

C:\Python27>c:\Python27\Scripts\virtualenv %VENV%
New python executable in c:\env\Scripts\python.exe
Installing setuptools, pip...done.

C:\Python27>cd\

C:\>cd env

C:\env>%VENV%\Scripts\easy_install "pyramid==1.5"
Searching for pyramid==1.5
Reading https://pypi.python.org/simple/pyramid/
Best match: pyramid 1.5
Downloading https://pypi.python.org/packages/source/p/pyramid/pyramid-1.5.tar.gz#md5=8747658dcbab709a9c491e43d3b0d58b
Processing pyramid-1.5.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-_ci7js\pyramid-1.5\setup.cfg
Running pyramid-1.5\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-_ci7js\pyramid-1.5\egg-dist-tmp-3di1fa
Adding pyramid 1.5 to easy-install.pth file
Installing ptweens-script.py script to c:\env\Scripts
Installing ptweens.exe script to c:\env\Scripts
Installing ptweens.exe.manifest script to c:\env\Scripts
Installing pdistreport-script.py script to c:\env\Scripts
Installing pdistreport.exe script to c:\env\Scripts
Installing pdistreport.exe.manifest script to c:\env\Scripts
Installing proutes-script.py script to c:\env\Scripts
Installing proutes.exe script to c:\env\Scripts
Installing proutes.exe.manifest script to c:\env\Scripts
Installing pshell-script.py script to c:\env\Scripts
Installing pshell.exe script to c:\env\Scripts
Installing pshell.exe.manifest script to c:\env\Scripts
Installing prequest-script.py script to c:\env\Scripts
Installing prequest.exe script to c:\env\Scripts
Installing prequest.exe.manifest script to c:\env\Scripts
Installing pviews-script.py script to c:\env\Scripts
Installing pviews.exe script to c:\env\Scripts
Installing pviews.exe.manifest script to c:\env\Scripts
Installing pcreate-script.py script to c:\env\Scripts
Installing pcreate.exe script to c:\env\Scripts
Installing pcreate.exe.manifest script to c:\env\Scripts
Installing pserve-script.py script to c:\env\Scripts
Installing pserve.exe script to c:\env\Scripts
Installing pserve.exe.manifest script to c:\env\Scripts

Installed c:\env\lib\site-packages\pyramid-1.5-py2.7.egg
Processing dependencies for pyramid==1.5
Searching for PasteDeploy>=1.5.0
Reading https://pypi.python.org/simple/PasteDeploy/
Best match: PasteDeploy 1.5.2
Downloading https://pypi.python.org/packages/source/P/PasteDeploy/PasteDeploy-1.5.2.tar.gz#md5=352b7205c78c8de4987578d19431af3b
Processing PasteDeploy-1.5.2.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-cfzau8\PasteDeploy-1.5.2\setup.cfg
Running PasteDeploy-1.5.2\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-cfzau8\PasteDeploy-1.5.2\egg-dist-tmp-f7vrej
Adding pastedeploy 1.5.2 to easy-install.pth file

Installed c:\env\lib\site-packages\pastedeploy-1.5.2-py2.7.egg
Searching for translationstring>=0.4
Reading https://pypi.python.org/simple/translationstring/
Best match: translationstring 1.1
Downloading https://pypi.python.org/packages/source/t/translationstring/translationstring-1.1.tar.gz#md5=0979b46d8f0f852810c8ec4be5c26cf2
Processing translationstring-1.1.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-ekrgr1\translationstring-1.1\setup.cfg
Running translationstring-1.1\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-ekrgr1\translationstring-1.1\egg-dist-tmp-o3xqh2
no previously-included directories found matching 'docs\_build'
Adding translationstring 1.1 to easy-install.pth file

Installed c:\env\lib\site-packages\translationstring-1.1-py2.7.egg
Searching for venusian>=1.0a3
Reading https://pypi.python.org/simple/venusian/
Best match: venusian 1.0a8
Downloading https://pypi.python.org/packages/source/v/venusian/venusian-1.0a8.tar.gz#md5=a1a72166fd7cccf0f30e3305e09ce5cf
Processing venusian-1.0a8.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-otkbse\venusian-1.0a8\setup.cfg
Running venusian-1.0a8\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-otkbse\venusian-1.0a8\egg-dist-tmp-wxnee2
Adding venusian 1.0a8 to easy-install.pth file

Installed c:\env\lib\site-packages\venusian-1.0a8-py2.7.egg
Searching for zope.deprecation>=3.5.0
Reading https://pypi.python.org/simple/zope.deprecation/
Best match: zope.deprecation 4.1.1
Downloading https://pypi.python.org/packages/source/z/zope.deprecation/zope.deprecation-4.1.1.tar.gz#md5=ce261b9384066f7e13b63525778430cb
Processing zope.deprecation-4.1.1.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-vv7_t0\zope.deprecation-4.1.1\setup.cfg
Running zope.deprecation-4.1.1\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-vv7_t0\zope.deprecation-4.1.1\egg-dist-tmp-g86gig
warning: no previously-included files matching '*.dll' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
Adding zope.deprecation 4.1.1 to easy-install.pth file

Installed c:\env\lib\site-packages\zope.deprecation-4.1.1-py2.7.egg
Searching for zope.interface>=3.8.0
Reading https://pypi.python.org/simple/zope.interface/
Best match: zope.interface 4.1.1
Downloading https://pypi.python.org/packages/2.7/z/zope.interface/zope.interface-4.1.1-py2.7-win32.egg#md5=97fc757b020bb25b829f9c566d87c8c3
Processing zope.interface-4.1.1-py2.7-win32.egg
creating c:\env\lib\site-packages\zope.interface-4.1.1-py2.7-win32.egg
Extracting zope.interface-4.1.1-py2.7-win32.egg to c:\env\lib\site-packages
Adding zope.interface 4.1.1 to easy-install.pth file

Installed c:\env\lib\site-packages\zope.interface-4.1.1-py2.7-win32.egg
Searching for repoze.lru>=0.4
Reading https://pypi.python.org/simple/repoze.lru/
Best match: repoze.lru 0.6
Downloading https://pypi.python.org/packages/source/r/repoze.lru/repoze.lru-0.6.tar.gz#md5=2c3b64b17a8e18b405f55d46173e14dd
Processing repoze.lru-0.6.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-sbw6vu\repoze.lru-0.6\setup.cfg
Running repoze.lru-0.6\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-sbw6vu\repoze.lru-0.6\egg-dist-tmp-o5ek4v
Adding repoze.lru 0.6 to easy-install.pth file

Installed c:\env\lib\site-packages\repoze.lru-0.6-py2.7.egg
Searching for WebOb>=1.3.1
Reading https://pypi.python.org/simple/WebOb/
Best match: WebOb 1.3.1
Downloading https://pypi.python.org/packages/source/W/WebOb/WebOb-1.3.1.tar.gz#md5=20918251c5726956ba8fef22d1556177
Processing WebOb-1.3.1.tar.gz
Writing c:\users\tracy\appdata\local\temp\easy_install-8x1ebc\WebOb-1.3.1\setup.cfg
Running WebOb-1.3.1\setup.py -q bdist_egg --dist-dir c:\users\tracy\appdata\local\temp\easy_install-8x1ebc\WebOb-1.3.1\egg-dist-tmp-dgnzem
no previously-included directories found matching '*.pyc'
no previously-included directories found matching '*.pyo'
Adding webob 1.3.1 to easy-install.pth file

Installed c:\env\lib\site-packages\webob-1.3.1-py2.7.egg
Finished processing dependencies for pyramid==1.5

C:\env>python pyramid_hello.py
Traceback (most recent call last):
  File "pyramid_hello.py", line 2, in <module>
    from pyramid.config import Configurator
  File "C:\Python27\lib\site-packages\pyramid-1.5-py2.7.egg\pyramid\config\__init__.py", line 11, in <module>
    from pyramid.interfaces import (
  File "C:\Python27\lib\site-packages\pyramid-1.5-py2.7.egg\pyramid\interfaces.py", line 1, in <module>
    from zope.deprecation import deprecated
ImportError: No module named deprecation

C:\env>

最佳答案

您的最后一个命令使用 C:\Python27 中的系统范围的 python,可使用 %PATH% 变量来使用它。

只需更改您的最后一个命令即可使用

C:\env>.\Scripts\python pyramid_hello.py

或者从包含脚本的任何目录中使用绝对路径通过 %VENV% python 解释器运行它。

c:\scripts>%VENV%\Scripts\python pyramid_hello.py

也许您会发现激活/停用 virtualenv 更方便。有经验的用户往往会明确说明,并且 Pyramid 文档通常不使用 virtualenv 激活。对于 Pyramid 初学者来说,这可能是他们第一步的好主意。只是口味问题。

关于python - Pyramid 网络框架 hello world 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23347100/

相关文章:

python - 在 Python Pyramid 中转到单个页面的所有地址(到单个 View 的全部路由)

python - 在 Pyramid 中,我可以根据请求方法让多个 View 指向同一路由/URL 吗?

python - Matplotlib:如何用等面积的箱子制作直方图?

python - 使用 Python 确定子目录是否位于已安装的文件系统上

python - 如何使用 python 正则表达式删除忽略 www.并且只提供域名?

python - py-postgresql多线程问题

python - 使用 numpy 一维数组作为 sklearn X 的最短语法

python - 在 Python 上使用多进程与 API 请求和多个 for 循环

python - Pyramid :从列表生成 json View

postgresql - 如何为点几何创建地质炼金术表达式?