1

I am new to python and pyglet, so this could be trivial question, but i was not able to find a solution so far. I am trying to export my application to a .exe with pyinstaller. I am able to create a .exe with the command

pyinstaller --hidden-import pkg_resources.py2_warn GameWindow.py

However, when i try to execute the GameWindow.exe i get several errors and the following traceback

Traceback (most recent call last):
  File "site-packages\pyglet\__init__.py", line 334, in __getattr__
AttributeError: 'NoneType' object has no attribute 'StaticSource'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "GameWindow.py", line 294, in <module>
  File "site-packages\pyglet\__init__.py", line 340, in __getattr__
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\users\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\pyglet\media\__init__.py", line 143, in <module>
  File "site-packages\pyglet\media\codecs\__init__.py", line 175, in add_default_media_codecs
  File "site-packages\pyglet\media\codecs\__init__.py", line 128, in add_decoders
  File "site-packages\pyglet\media\codecs\wmf.py", line 881, in get_decoders
  File "site-packages\pyglet\media\codecs\wmf.py", line 829, in __init__
  File "_ctypes/callproc.c", line 935, in GetResult
OSError: [WinError -2147417850] Cannot change thread mode after it is set
[11808] Failed to execute script GameWindow
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\users\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\pyglet\media\__init__.py", line 143, in <module>
  File "site-packages\pyglet\media\codecs\__init__.py", line 175, in add_default_media_codecs
  File "site-packages\pyglet\media\codecs\__init__.py", line 128, in add_decoders
  File "site-packages\pyglet\media\codecs\wmf.py", line 881, in get_decoders
  File "site-packages\pyglet\media\codecs\wmf.py", line 829, in __init__
  File "_ctypes/callproc.c", line 935, in GetResult
OSError: [WinError -2147417850] Cannot change thread mode after it is set
Exception ignored in: <function WMFDecoder.__del__ at 0x000002594E230318>
Traceback (most recent call last):
  File "site-packages\pyglet\media\codecs\wmf.py", line 876, in __del__
AttributeError: 'WMFDecoder' object has no attribute 'MFShutdown'
Exception ignored in: <function WMFDecoder.__del__ at 0x000002594E230318>
Traceback (most recent call last):
  File "site-packages\pyglet\media\codecs\wmf.py", line 876, in __del__
AttributeError: 'WMFDecoder' object has no attribute 'MFShutdown'

i tried to use pyinstaller --hidden-import=['pkg_resources.py2_warn', 'WMFDecoder.MFShutdown'] GameWindow.py, but doesn't help.

Do you have any suggestion on how to solve this issue?

Fed
  • 207
  • 2
  • 14
  • Your problem isn't `WMFDecoder.MFShutdown` so no need to additionally import that. Your problem is `StaticSource`, You're trying some where in your code to do `x.StaticSource` where `x` is `None` when executed, so I'd like for you to show us the relevant code. – Torxed May 21 '20 at 08:03

1 Answers1

-1

Hi im new to this website so I cannot comment on your post to ask for some clarification.\

Why are you using --hidden-imports? You could use

     pyinstaller --onefile pythonScriptName.py
muzykfs
  • 62
  • 3
  • Hi,thanks for your answer. I used --hidden-imports because the command "pyinstaller --onefile GameWindow.py" was giving me the folllowing error: ModuleNotFoundError: "No module named 'pkg_resources.py2_warn'", and i used the suggestion indicated here: https://stackoverflow.com/questions/37815371/pyinstaller-failed-to-execute-script-pyi-rth-pkgres-and-missing-packages – Fed May 20 '20 at 15:11
  • I can also use : "pyinstaller --hidden-import pkg_resources.py2_warn --onefile GameWindow.py", but then i run again in the same problem of the main question: "AttributeError: 'NoneType' object has no attribute 'StaticSource'" – Fed May 20 '20 at 15:29