运行bin / python setup.py test-q的生产服务器上的语法错误

时间:2013-03-11 14:24:43

标签: python python-3.x pyramid

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

    $ 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

3 个答案:

答案 0 :(得分:2)

这是Python 3,你应该写as

except HTTPException as exc:

答案 1 :(得分:0)

我花了几天时间才弄明白&gt;&lt;。但请确保安装正确的mod_wsgi版本。您可以安装使用python2或使用python3的那个。

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

答案 2 :(得分:0)

你只需使用这个补丁。

$ 2to3 example.py

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

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