1

当我尝试在生产服务器上执行以下操作时:

    $ sudo -u vretnet ../bin/python setup.py test -q

它会显示以下错误,我应该如何解决这个问题?还是我的 development.ini 出错了?

    Traceback (most recent call last):
    File "setup.py", line 34, in <module>
        paster_plugins=['pyramid'],
    File "/opt/python3.2.3/lib/python3.2/distutils/core.py", line 148, in setup
        dist.run_commands()
    File "/opt/python3.2.3/lib/python3.2/distutils/dist.py", line 917, in run_commands
        self.run_command(cmd)
    File "/opt/python3.2.3/lib/python3.2/distutils/dist.py", line 936, in run_command
        cmd_obj.run()
    File "/home/vretnet/env/lib/python3.2/site-packages/distribute-0.6.34-py3.2.egg/setuptools/command/test.py", line 138, in run self.with_project_on_sys_path(self.run_tests)
    File "/home/vretnet/env/lib/python3.2/site-packages/distribute-0.6.34-py3.2.egg/setuptools/command/test.py", line 118, in with_project_on_sys_path 
        func()
    File "/home/vretnet/env/lib/python3.2/site-packages/distribute-0.6.34-py3.2.egg/setuptools/command/test.py", line 164, in run_tests
        testLoader = cks
    File "/opt/python3.2.3/lib/python3.2/unittest/main.py", line 123, in __init__
        self.parseArgs(argv)
    File "/opt/python3.2.3/lib/python3.2/unittest/main.py", line 191, in parseArgs
        self.createTests()
    File "/opt/python3.2.3/lib/python3.2/unittest/main.py", line 198, in createTests
        self.module)
    File "/opt/python3.2.3/lib/python3.2/unittest/loader.py", line 132, in loadTestsFromNames
        suites = [self.loadTestsFromName(name, module) for name in names]
    File "/opt/python3.2.3/lib/python3.2/unittest/loader.py", line 132, in <listcomp>
        suites = [self.loadTestsFromName(name, module) for name in names]
    File "/opt/python3.2.3/lib/python3.2/unittest/loader.py", line 91, in loadTestsFromName
        module = __import__('.'.join(parts_copy))
    File "/home/vretnet/env/ECommerce/ecommerce/__init__.py", line 1, in <module>
        from pyramid.config import Configurator
    File "/home/vretnet/env/lib/python3.2/site-packages/pyramid-1.4-py3.2.egg/pyramid/config/__init__.py", line 10, in <module>
        from webob.exc import WSGIHTTPException as WebobWSGIHTTPException
    File "/home/vretnet/env/lib/python3.2/site-packages/WebOb-1.2.3-py3.2.egg/webob/exc.py", line 1115, in <module>
        from paste import httpexceptions
    File "/home/vretnet/env/lib/python3.2/site-packages/Paste-1.7.5.1-py3.2.egg/paste/httpexceptions.py", line 634
        except HTTPException, exc:
                    ^
    SyntaxError: invalid syntax
4

3 回答 3

2

它是 Python 3,你应该写as

except HTTPException as exc:
于 2013-03-11T14:32:35.843 回答
0

这花了我几天时间才弄明白><。但请确保您安装了正确的 mod_wsgi 版本。您可以安装使用 python2 或使用 python3 的安装。

如果您安装 python3 wsgi mod 并使用 virtualenv2 来构建您的 python 环境,您将获得不是为 python3 编写的包。

于 2014-08-20T09:47:38.133 回答
0

你只需使用下面的这个补丁。

$ 2to3 example.py

https://docs.python.org/2.7/library/2to3.html#to3-python-2-3

自动递归地将代码从 python2 转换为 python3。

于 2014-11-20T12:05:04.080 回答