Pyglet sprite.draw() crashing on iGPU - python

I've written the following python loop to display multiple gif files one after another. The code works fine on one of my machines with a dedicated GPU but only displays one gif on my laptop with an AMD iGPU displaying the following error msg after closing the first window (both PCs run windows 10):
import pyglet
def play_animation(ag_file):
animation = pyglet.image.load_animation(ag_file)
sprite = pyglet.sprite.Sprite(animation)
win = pyglet.window.Window(width=sprite.width, height=sprite.height)
green = 0, 1, 0, 1
pyglet.gl.glClearColor(*green)
#win.event
def on_draw():
win.clear()
sprite.draw()
pyglet.app.run()
if __name__ == '__main__':
gif_list = ['gif1.gif', 'gif2.gif']
for gif in gif_list:
print(gif)
play_animation(gif)
And the error I get after I close the first animation is:
gif1.gif
gif2.gif
Traceback (most recent call last):
File "main.py", line 226, in <module>
play_animation(Save_Name)
File "main.py", line 29, in play_animation
pyglet.app.run()
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\app\__init__.py", line 107, in run
event_loop.run(interval)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\app\base.py", line 186, in run
timeout = self.idle()
^^^^^^^^^^^
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\app\base.py", line 247, in idle
self.clock.call_scheduled_functions(dt)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\clock.py", line 262, in call_scheduled_functions
item.func(now - item.last_ts, *item.args, **item.kwargs)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\app\base.py", line 153, in _redraw_windows
window.dispatch_event('on_draw')
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\window\__init__.py", line 1363, in dispatch_event
super().dispatch_event(*args)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\event.py", line 415, in dispatch_event
if handler(*args):
^^^^^^^^^^^^^^
File "main.py", line 19, in on_draw
sprite.draw()
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\sprite.py", line 820, in draw
self._vertex_list.draw(GL_TRIANGLES)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\graphics\vertexdomain.py", line 276, in draw
self.domain.draw_subset(mode, self)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\graphics\vertexdomain.py", line 491, in draw_subset
self.vao.bind()
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\graphics\vertexarray.py", line 58, in bind
glBindVertexArray(self._id)
File "C:\Users\..\AppData\Roaming\Python\Python311\site-packages\pyglet\gl\lib.py", line 114, in errcheck
raise GLException('(0x%x): %s' % (error, msg))
pyglet.gl.lib.GLException: (0x502): Invalid operation. The specified operation is not allowed in the current state.
I updated the driver on both machines and installed the latest version of python (3.11) and pyglet (2.0.2.1) as well as all Updates for windows

Related

When trying to run a pyglet window, I get this error: "AttributeError: 'scipy.spatial.transform._rotation.Rotation' object has no attribute 'as_dcm'"

This is all my code
import pyglet
import ratcave as rc
window = pyglet.window.Window()
pyglet.app.run()
When running this, the following shows in terminal
Traceback (most recent call last):
File "c:\CODING\pyopengl\Mudge-David-Homework-8.py", line 14, in <module>
import ratcave as rc
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\__init__.py", line 5, in <module>
from . import resources
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\resources.py", line 40, in <module>
default_camera = Camera()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 260, in __init__
self.projection = PerspectiveProjection() if not projection else projection
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\utils\observers.py", line 56, in __setattr__
super(AutoRegisterObserver, self).__setattr__(key, value)
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 299, in projection
self.reset_uniforms()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 302, in reset_uniforms
self.uniforms['projection_matrix'] = self.projection_matrix.view()
PS C:\Users\David> & C:/Users/David/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/CODING/pyopengl/Mudge-David-Homework-8.py
Traceback (most recent call last):
File "c:\CODING\pyopengl\Mudge-David-Homework-8.py", line 14, in <module>
import ratcave as rc
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\__init__.py", line 5, in <module>
from . import resources
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\resources.py", line 40, in <module>
default_camera = Camera()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 260, in __init__
self.projection = PerspectiveProjection() if not projection else projection
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\utils\observers.py", line 56, in __setattr__
super(AutoRegisterObserver, self).__setattr__(key, value)
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 299, in projection
self.reset_uniforms()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 302, in reset_uniforms
self.uniforms['projection_matrix'] = self.projection_matrix.view()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\shader.py", line 139, in uniforms
self.update()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\utils\observers.py", line 47, in update
self.on_change()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\physical.py", line 186, in on_change
Physical.on_change(self)
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\physical.py", line 138, in on_change
self.model_matrix = np.dot(self.position.to_matrix(), self.rotation.to_matrix())
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\coordinates.py", line 126, in to_matrix
return self.to_radians().to_matrix()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\coordinates.py", line 95, in to_matrix
mat[:3, :3] = R.from_euler(self.axes[1:],self._array,degrees=False).as_dcm() # scipy as_matrix() not available
AttributeError: 'scipy.spatial.transform._rotation.Rotation' object has no attribute 'as_dcm'
With seemingly the error being that final line
AttributeError: 'scipy.spatial.transform._rotation.Rotation' object has no attribute 'as_dcm'
Im trying to follow this tutorial
The code should create a new window, which in turn means Pyglet is working.
From what I have researched, this has been solved through SciPy methods being changed, which I have attempted with no luck. Another thread of this issue resolved it by installing the correct version, which would correct these methods. However I have attempted to install different versions of SciPy and still get the same error.
The as_dcm() method of the Rotation class was deprecated in SciPy version 1.4.0 and removed from SciPy version 1.6.0. You'll have to use an older version of SciPy, or find out if there is a version of ratcave that works with the latest version of SciPy.

pygame game crashes when I edit tilesheets in tiled

I am trying to make a game with pygame using tiled. When I edit tilesheets (to for example add collision) I get a bunch of error messages when I run my code.
When I use the same tilesheet without editing I get no errors and all the files work.
Traceback (most recent call last):
File "C:/Users/47988/PycharmProjects/Terrible/Main.py", line 94, in
<module>
g = Game()
File "C:/Users/47988/PycharmProjects/Terrible/Main.py", line 16, in init
self.load_data()
File "C:/Users/47988/PycharmProjects/Terrible/Main.py", line 22, in load_data
self.map = TiledMap(path.join(map_folder, "map6.tmx"))
File "C:\Users\47988\PycharmProjects\Terrible\Tilemap.py", line 21, in init
tm = pytmx.load_pygame(filename, pixelalpha=True)
File "C:\Users\47988\PycharmProjects\Terrible\venv\lib\site- packages\pytmx\util_pygame.py", line 141, in load_pygame
return pytmx.TiledMap(filename, *args, **kwargs)
File "C:\Users\47988\PycharmProjects\Terrible\venv\lib\site-packages\pytmx\pytmx.py", line 360, in init
self.parse_xml(ElementTree.parse(self.filename).getroot())
File "C:\Users\47988\PycharmProjects\Terrible\venv\lib\site- packages\pytmx\pytmx.py", line 400, in parse_xml
self.add_tileset(TiledTileset(self, subnode))
File "C:\Users\47988\PycharmProjects\Terrible\venv\lib\site-packages\pytmx\pytmx.py", line 845, in init
self.parse_xml(node)
File "C:\Users\47988\PycharmProjects\Terrible\venv\lib\site-packages\pytmx\pytmx.py", line 874, in parse_xml
raise Exception
Exception
Is there any way of solving this?

Robot framework [ ERROR ] Unexpected error: IOError: [Errno 0] Error

I have this weird error that I have never seen before. I ran an RF automation regression test using Chrome and after a while, I got this error which basically stops the test execution and does not provide any test results.
I also noticed this new text line that I haven't seen before during text execution:
DevTools listening on
ws://127.0.0.1:12306/devtools/browser/df1c8bcc-867c-41bc-a9b4-c364bdfafec2
(The test scripts have been used before & passed without any issues)
W8-BENE date format - ddMMMMMyyyyDot :: This is to test the differ...
DevTools listening on
ws://127.0.0.1:12537/devtools/browser/6d32afb6-90f2-46d4-a18a-001fa61d2444
[ ERROR ] Unexpected error: IOError: [Errno 0] Error Traceback (most
recent call last): File
"c:\python27\lib\site-packages\robot\utils\application.py", line 83,
in _execute
rc = self.main(arguments, **options)
File "c:\python27\lib\site-packages\robot\run.py", line 445, in main
result = suite.run(settings)
File "c:\python27\lib\site-packages\robot\running\model.py", line
248, in run
self.visit(runner)
File "c:\python27\lib\site-packages\robot\model\testsuite.py", line
161, in visit
visitor.visit_suite(self)
File "c:\python27\lib\site-packages\robot\model\visitor.py", line
87, in visit_suite
suite.tests.visit(self)
File "c:\python27\lib\site-packages\robot\model\itemlist.py", line
76, in visit
item.visit(visitor)
File "c:\python27\lib\site-packages\robot\model\testcase.py", line
74, in visit
visitor.visit_test(self)
File "c:\python27\lib\site-packages\robot\running\runner.py", line
151, in visit_test
result)
File "c:\python27\lib\site-packages\robot\running\runner.py", line
182, in _run_teardown
exception = self._run_setup_or_teardown(teardown)
File "c:\python27\lib\site-packages\robot\running\runner.py", line
201, in _run_setup_or_teardown
StepRunner(self._context).run_step(data, name=name)
File "c:\python27\lib\site-packages\robot\running\steprunner.py",
line 57, in run_step
return runner.run(step, context)
File
"c:\python27\lib\site-packages\robot\running\librarykeywordrunner.py",
line 56, in run
return return_value File "c:\python27\lib\site-packages\robot\running\statusreporter.py", line
54, in exit
context.end_keyword(result)
File "c:\python27\lib\site-packages\robot\running\context.py", line
179, in end_keyword
self.output.end_keyword(keyword)
File "c:\python27\lib\site-packages\robot\output\output.py", line
65, in end_keyword
LOGGER.end_keyword(kw)
File "c:\python27\lib\site-packages\robot\output\logger.py", line
195, in end_keyword
logger.end_keyword(keyword)
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
62, in end_keyword
self._writer.keyword_marker(kw.status)
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
136, in keyword_marker
self._clear_status()
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
124, in _clear_status
self._write_info()
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
90, in _write_info
self._stdout.write(self._last_info)
File
"c:\python27\lib\site-packages\robot\output\console\highlighting.py",
line 51, in write
self.stream.write(console_encode(text, stream=self.stream))
W8-BENE date format - ddMMMMMyyyyDot :: This is to test the differ...
C:\Development\robot-scripts\WebApp>
Has anyone had the same issue? I can't seem to find any solution. I uninstalled and reinstalled everything even update all the web drivers.
I had the same error after update to WIN 10. Just did fresh python install and it works fine for me. also look here: https://github.com/robotframework/robotframework/issues/2709

Open a new instance of AutoCAD via Python

Does anyone have any experience using Python with AutoCAD? I'm just trying, as a test to see if I can open a new instance of AutoCAD via Python and though that PyAutocad worked well (feel free to offer other suggestions, if you have any).
Anyway based on the doc (https://pypi.python.org/pypi/pyautocad/#downloads) - it says these lines of code should do it, but nothing's happened as of yet.
from pyautocad import Autocad, APoint
acad = Autocad()
acad.prompt("Hello, Autocad from Python\n")
Just these lines of code should generate info on the commandline but instead results in about 50 lines worth of traceback (which I can post as well if anyone's interested) - any ideas?
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
acad.prompt("Hello, Autocad")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 54, in app
self._app = comtypes.client.GetActiveObject('AutoCAD.Application')
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 180, in GetActiveObject
obj = comtypes.GetActiveObject(clsid, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\__init__.py", line 1165, in GetActiveObject
oledll.oleaut32.GetActiveObject(byref(clsid), None, byref(p))
File "_ctypes/callproc.c", line 941, in GetResult
WindowsError: [Error -2147221021] Operation unavailable
After adding the VBA Module, the traceback now reads:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
acad.prompt("Hello")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 54, in app
self._app = comtypes.client.GetActiveObject('AutoCAD.Application')
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 183, in GetActiveObject
return _manage(obj, clsid, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: 'module' object has no attribute 'IAcadApplication'
Now after deleting comtypes' "gen" folder per #reclosedev, Autocad now opens but the string of text still will not appear on the command line - the traceback reads:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
acad.prompt("Hello")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 59, in app
self._app.Visible = self._visible
File "C:\Python27\lib\site-packages\comtypes\client\dynamic.py", line 116, in __setattr__
dispid = self._comobj.GetIDsOfNames(name)[0]
File "C:\Python27\lib\site-packages\comtypes\automation.py", line 643, in GetIDsOfNames
self.__com_GetIDsOfNames(riid_null, arr, len(names), lcid, ids)
COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0, None))
Have you considered IronPython?
http://through-the-interface.typepad.com/through_the_interface/2009/03/using-ironpython-with-autocad.html
Here's a quick example of how it could be leveraged:
import clr
import System
from System import Type, Activator
acApp = Activator.CreateInstance(Type.GetTypeFromProgID("AutoCAD.Application"))
acApp.Visible = 1
acApp.ActiveDocument.SendCommand("(Princ \"Hello World from Python!\")(Princ)\n")
Obviously the ProgId will correspond to whichever version of AutoCAD was opened last.

pylint PyQt4 error

I write a program :
from PyQt4.QtCore import *
from PyQt4.QtGui import *
def main():
app = QApplication([])
button = QPushButton("hello?")
button.show()
app.exec_()
if __name__=="__main__":
main()
the file name is t.py,
when I run:
pylint t.py
in ubuntu9.10, pyqt4,
I got this:
pylint t.py
No config file found, using default configuration
error while building astng for /home/halida/data/workspace/test/t.py
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/logilab/astng/manager.py", line 126, in astng_from_file
astng = ASTNGBuilder(self).file_build(filepath, modname)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 118, in file_build
node = self.string_build(data, modname, path)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 128, in string_build
return self.ast_build(parse(data + '\n'), modname, path)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 147, in ast_build
self.rebuilder.walk(node)
File "/usr/lib/pymodules/python2.6/logilab/astng/rebuilder.py", line 89, in walk
self._walk(node)
File "/usr/lib/pymodules/python2.6/logilab/astng/rebuilder.py", line 109, in _walk
self._walk(child, node)
File "/usr/lib/pymodules/python2.6/logilab/astng/rebuilder.py", line 103, in _walk
handle_leave = node.accept(self)
File "/usr/lib/pymodules/python2.6/logilab/astng/nodes.py", line 159, in accept
return func(self)
File "/usr/lib/pymodules/python2.6/logilab/astng/rebuilder.py", line 188, in visit_from
imported = node.root().import_module(node.modname)
File "/usr/lib/pymodules/python2.6/logilab/astng/scoped_nodes.py", line 282, in import_module
return MANAGER.astng_from_module_name(self.relative_name(modname, level))
File "/usr/lib/pymodules/python2.6/logilab/astng/manager.py", line 172, in astng_from_module_name
return self.astng_from_module(module, modname)
File "/usr/lib/pymodules/python2.6/logilab/astng/manager.py", line 207, in astng_from_module
astng = ASTNGBuilder(self).module_build(module, modname)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 80, in module_build
node = self.inspect_build(module, modname=modname, path=path)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 95, in inspect_build
self.object_build(node, module)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 195, in object_build
self.object_build(class_node, member)
File "/usr/lib/pymodules/python2.6/logilab/astng/builder.py", line 198, in object_build
object_build_methoddescriptor(node, member)
File "/usr/lib/pymodules/python2.6/logilab/astng/raw_building.py", line 150, in object_build_methoddescriptor
func = build_function(member.__name__, doc=member.__doc__)
AttributeError: 'PyQt4.QtCore.pyqtSignal' object has no attribute '__name__'
************* Module t
F: 1: <class 'logilab.astng._exceptions.ASTNGBuildingException'>: Unable to load module t ('PyQt4.QtCore.pyqtSignal' object has no attribute '__name__')
Compilation exited abnormally with code 1 at Sat Dec 26 10:43:54
in windows XP, with pythonxy,
I only got a error message, why?
Looks like a bug in astng. They try to read the name of a function which does not publish it (native extension func). I'd report a bug to both astng and pyqt projects. The first one would be that they should handle a no-name situation better. The second one would be that every sane extension should publish at least the function names.
I would check if you're using the very latest astng, pylint, etc.

Categories

Resources