gpt4 book ai didi

python - 交互运行 pyprocessing 脚本时出现 TypeError : super(type, obj)

转载 作者:太空宇宙 更新时间:2023-11-03 18:26:10 25 4
gpt4 key购买 nike

Python 2.7.3:

创建尽可能简单的pyprocessing文件并将其另存为 foo.py:

from pyprocessing import *

def setup():
size(100,100)

def draw():
rect(10,10,10,10)

run()

现在在Python中:

>>> execfile('foo.py')

文件按预期运行。关闭 pyprocessing 窗口返回提示符并输入:

>>> execfile('foo.py')

迎接您的是:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "foo.py", line 9, in <module>
run()
File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/__init__.py", line 417, in run
__main__.setup()
File "foo.py", line 4, in setup
size(100,100)
File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/__init__.py", line 335, in size
config=canvas.config, caption=caption, visible = isVisible)
File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/flippolicy.py", line 142, in __init__
super(BackupWindow, self).__init__(*args, **keyargs)
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/xlib/__init__.py", line 474, in __init__
super(XlibWindow, self).__init__(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/__init__.py", line 690, in __init__
self.set_visible(True)
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/xlib/__init__.py", line 878, in set_visible
self._map()
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/xlib/__init__.py", line 710, in _map
self.dispatch_event('on_resize', self._width, self._height)
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/__init__.py", line 1219, in dispatch_event
EventDispatcher.dispatch_event(self, *args)
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/event.py", line 352, in dispatch_event
event_type, args, getattr(self, event_type))
File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/event.py", line 349, in dispatch_event
return getattr(self, event_type)(*args)
File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/flippolicy.py", line 168, in on_resize
super (FBOWindow, self).on_resize(w,h)
TypeError: super(type, obj): obj must be an instance or subtype of type

这里发生了什么?这是一个错误吗?我使用 pyprocessing 是否错误?

最佳答案

这相当于 subprocess每次都会产生一个单独的进程:

from subprocess import call 
call([sys.executable, 'foo.py'])

参见this SO question有关 subprocess.call 的更全面讨论。

关于python - 交互运行 pyprocessing 脚本时出现 TypeError : super(type, obj),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23155140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com