Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Python&;Pyglet Minecraft示例代码错误_Python 3.x_Python 3.3_Pyglet - Fatal编程技术网

Python 3.x Python&;Pyglet Minecraft示例代码错误

Python 3.x Python&;Pyglet Minecraft示例代码错误,python-3.x,python-3.3,pyglet,Python 3.x,Python 3.3,Pyglet,因此,我在Mac上构建了Pyglet,并尝试将其与Minecraft(Python)演示代码一起使用,但我遇到了这个错误,我意识到它源于Pyglet本身。以下是完整的错误: Traceback (most recent call last): File "/Users/Noah/Desktop/PyCraft/main.py", line 892, in <module> main() File "/Users/Noah/Desktop/PyCraft/main.py

因此,我在Mac上构建了Pyglet,并尝试将其与Minecraft(Python)演示代码一起使用,但我遇到了这个错误,我意识到它源于Pyglet本身。以下是完整的错误:

Traceback (most recent call last):
  File "/Users/Noah/Desktop/PyCraft/main.py", line 892, in <module>
    main()
  File "/Users/Noah/Desktop/PyCraft/main.py", line 890, in main
    pyglet.app.run()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/__init__.py", line 123, in run
    event_loop.run()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/base.py", line 127, in run
    self._legacy_setup()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/base.py", line 218, in _legacy_setup
    window.dispatch_pending_events()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/window/cocoa/__init__.py", line 324, in dispatch_pending_events
    EventDispatcher.dispatch_event(self, *event)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/event.py", line 369, in dispatch_event
    event_type, args, getattr(self, event_type))
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/event.py", line 365, in dispatch_event
    if getattr(self, event_type)(*args):
  File "/Users/Noah/Desktop/PyCraft/main.py", line 767, in on_resize
    ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n))
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/__init__.py", line 289, in vertex_list
    return _get_default_batch().add(count, 0, None, *data)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/__init__.py", line 359, in add
    vlist._set_attribute_data(i, array)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/vertexdomain.py", line 440, in _set_attribute_data
    region.array[:] = data
TypeError: int expected instead of float
回溯(最近一次呼叫最后一次):
文件“/Users/Noah/Desktop/PyCraft/main.py”,第892行,在
main()
main中第890行的文件“/Users/Noah/Desktop/PyCraft/main.py”
pyglet.app.run()文件
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/app/_-init____;.py”,第123行,正在运行
event_loop.run()
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/app/base.py”,第127行,运行中
self._legacy_setup()
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/app/base.py”,第218行,在“遗留”设置中
window.dispatch_pending_事件()
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/window/cococa/__init____;.py”,第324行,在dispatch_pending_u事件中
EventDispatcher.Dispatcher\u事件(self,*事件)
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/event.py”,第369行,在dispatch_事件中
事件类型,参数,getattr(自身,事件类型))
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/event.py”,第365行,在dispatch_事件中
如果getattr(自身,事件类型)(*args):
文件“/Users/Noah/Desktop/PyCraft/main.py”,第767行,在on_中调整大小
('v2i',(x-n,y,x+n,y,x,y-n,x,y+n))
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/graphics/_init____;.py”,vertex_列表第289行
返回_get_default_batch()。添加(计数、0、无、*数据)
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyglet/graphics/_-init____;.py”,第359行,添加
vlist.\u集合\u属性\u数据(i,数组)
文件“/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site packages/pyglet/graphics/vertexdomain.py”,第440行,在属性数据中
region.array[:]=数据
TypeError:应为int而不是float

任何意见都会有帮助。谢谢

基本类型错误是您试图将数字(即1)设置为浮点(即1.1)。 将您的代码放在粘贴箱上会非常有用


谢谢,Jonathan在我看来,另一个问题在于您使用的是Python 3.3。Pyglet支持2.x

  File "/Users/Noah/Desktop/PyCraft/main.py", line 767, in on_resize
    ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n))
以及:

v2i,i代表整数,但您正在传递浮点。将最后一行更改为

        x, y = self.width // 2, self.height // 2

我做了2吨,但我想这不包括任何内容。谢谢
        x, y = self.width // 2, self.height // 2