3

after I converted my PY file to EXE and I ran it, I got this error:

Traceback (most recent call last):
  File "PrngCipher.py", line 2, in <module>
    from kivy.app import App
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "kivy\__init__.py", line 272, in <module>
  File "C:\Program Files\Python39\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py", line 71, in _pyi_pkgutil_iter_modules
    assert pkg_path.startswith(SYS_PREFIX)
TypeError: startswith first arg must be str or a tuple of str, not PureWindowsPath

I'm new to Python and PyInstaller, I don't know what this error is about, I followed many tutorials and hooked the right dependencies into the .spec file but it still broke. My .py, .kv and .spec file: https://drive.google.com/drive/folders/1F7I4xEphB3d2ErDPs7vGDpT7trTmHKgC?usp=sharing

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175

3 Answers3

1

I did more research and looked into the upper lines of the error message and I found out the problem was at the PyInstaller pakage's code not my code, the fix is to downgrade PyInstaller to 4.3 waiting for a fix using python -m pip install PyInstaller==4.3 and it worked fine

0

The error is telling you that you are using startsWith with wrong parameter types, notably, it expects a String to be the first parameter, while you pass PureWindowsPath instead. I'm not a Python specialist, but I believe that you could solve it via calling .__str__() for the variable that you aim to pass, so its value will be represented as a String when being passed to startsWith.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • I don't know what is the `startsWith` so I can't really debug which part it was in my code, thank you for simplifying the error message though – SilencedFrost Jul 21 '21 at 12:58
0

It's a regression bug in PyInstaller 4.4: [GitHub]: pyinstaller/pyinstaller - TypeError: startswith first arg must be a str or tuple of str, not PurePosixPath.
It was already fixed (by [GitHub]: pyinstaller/pyinstaller - hooks: pkgutil rthook: declare SYS_PREFIX as function-local symbol), but the fix will only be available in the next release, which (considering the bug severity) should be available soon.

Ways to go further:

CristiFati
  • 38,250
  • 9
  • 50
  • 87