简体   繁体   English

Python在pygame中使用pgu导入时引发异常

[英]Python throws exception on import using pgu with pygame

When I from pgu import pgu as pgui I get the following exception: 当我from pgu import pgu as pgui ,出现以下异常:

Traceback (most recent call last):
  File "C:/path/pyspace/main.py", line 3, in <module>
    from simulator.game import Game
  File "C:\path\pyspace\simulator\game.py", line 5, in <module>
    from simulator.guis.simulategui import SimulateGUI
  File "C:\path\pyspace\simulator\guis\__init__.py", line 2, in <module>
    from simulator.guis.simulategui import SimulateGUI
  File "C:\path\pyspace\simulator\guis\simulategui.py", line 5, in <module>
    from pgu import gui as pgui
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\pgu\gui\__init__.py", line 21, in <module>
    from .container import Container
  File "C:\Program Files (x86)\Python35-32\lib\site-packages\pgu\gui\container.py", line 57
    except StyleError,e:

when I open the ...\\gui\\container.py with pycharm there is an error that tells me that Python version 3.5 does not support this syntax . 当我使用pycharm打开...\\gui\\container.py ,出现错误,告诉我Python version 3.5 does not support this syntax The syntax in container.py in pgu is as follows: pgucontainer.py中的语法如下:

        try:
            # This hack isn't perfect and so it's not enabled by default, but only by
            # themes that explicitly request it.
            alpha = pguglobals.app.theme.getstyle("pgu", "", "themealpha")
        except StyleError,e:
            alpha = False

I am running python 3.5.1 with pygame 1.9.2a0 and pgu 0.18. 我正在用pygame 1.9.2a0和pgu 0.18运行python 3.5.1。 Do I need to install a different version of pgu or different version of a GUI manager for pygame altogether, or is there a simple way to solve this? 我是否需要为pygame完全安装其他版本的pgu或其他版本的GUI管理器,还是有解决此问题的简单方法? I'm assuming I get to install a different GUI manager; 我假设我要安装其他GUI管理器。 but was hoping that there is a simple fix to this. 但希望对此有一个简单的解决方法。

It looks like pgu is still using Python 2.7 exception handling. 看来pgu仍在使用Python 2.7异常处理。 You could change your local copy to read 您可以将本地副本更改为

except StyleError as e:

but that would still have to be sent upstream if you're redistributing the code. 但是如果您要重新分发代码,则仍必须将其发送到上游。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM