Minecraft icon indicating copy to clipboard operation
Minecraft copied to clipboard

AttributeError: 'Window' object has no attribute 'get_viewport_size' on Ubuntu 18.04 LTS (64-Bit) with system-provided pyglet package

Open juozaspo opened this issue 6 years ago • 3 comments

While trying to run the game in Ubuntu Linux 18.04 (64-bit) with system-provided pyglet package (python-pyglet), game fails with the following error:

$ python main.py 
Traceback (most recent call last):
  File "main.py", line 902, in <module>
    main()
  File "main.py", line 898, in main
    pyglet.app.run()
  File "/usr/lib/python2.7/dist-packages/pyglet/app/__init__.py", line 138, in run
    event_loop.run()
  File "/usr/lib/python2.7/dist-packages/pyglet/app/base.py", line 142, in run
    self._run()
  File "/usr/lib/python2.7/dist-packages/pyglet/app/base.py", line 154, in _run
    timeout = self.idle()
  File "/usr/lib/python2.7/dist-packages/pyglet/app/base.py", line 281, in idle
    window.dispatch_event('on_draw')
  File "/usr/lib/python2.7/dist-packages/pyglet/window/__init__.py", line 1220, in dispatch_event
    if EventDispatcher.dispatch_event(self, *args) != False:
  File "/usr/lib/python2.7/dist-packages/pyglet/event.py", line 367, in dispatch_event
    if getattr(self, event_type)(*args):
  File "main.py", line 814, in on_draw
    self.set_3d()
  File "main.py", line 796, in set_3d
    viewport = self.get_viewport_size()
AttributeError: 'Window' object has no attribute 'get_viewport_size'

Pyglet and other package versions to be installed in ubuntu

libjs-underscore 1.8.3~dfsg-1
libjs-sphinxdoc 1.6.7-1ubuntu1
python-configparser 3.5.0-1
python-future 0.15.2-4ubuntu2
python-pyglet 1.3.0-1

After uninstalling system-provided pyglet package and installing pyglet through pip game works fine, also pip provides newer versions (pyglet-1.4.1 and future-0.17.1) instead.

juozaspo avatar Jul 30 '19 14:07 juozaspo

I created a pull request that fixes this problem: https://github.com/fogleman/Minecraft/pull/109 It is not a perfect solution, because it uses window size, not viewport size, but it works for me.

jakubthedeveloper avatar Nov 21 '19 11:11 jakubthedeveloper

I'll look into this later today. Your commit unfortunately reverts the commit I made 8 months ago to fix an issue that using window size causes on Mac. It shouldn't be to much trouble to implement a check and apply different solutions so that one package can work for both Mac and Linux.

OneSharpAce avatar Nov 26 '19 05:11 OneSharpAce

I think you can check if method get_viewport_size exists and depending on the result of the check use this method or window size.

jakubthedeveloper avatar Nov 26 '19 15:11 jakubthedeveloper