1

I used the following command to create the spec file: pyinstaller main.py -w

from kivy_deps import sdl2, glew
# -*- mode: python ; coding: utf-8 -*-
 
 
block_cipher = None
 
 
a = Analysis(['main.py'],
             pathex=['C:\\Users\\Administrator\\PycharmProjects\\touchtracer\\TouchApp'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
 
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='main',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=False,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None )
coll = COLLECT(exe, Tree('C:\\Users\\Administrator\\PycharmProjects\\touchtracer\\'),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               upx_exclude=[],
               name='main')

I used the following command to update the .spec file: pyinstaller main.spec -y

I am getting the following error when trying to launch the exe:

File "main.py", line 28, in <module>
 import kivy
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "kivy\__init__.py", line 272, in <module>
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\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

How can i resolve this error?

Kunal M
  • 47
  • 1
  • 5
  • What's your *Python* version: `"C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe" -c "import sys;print(sys.version)"`? Is it a regular installation, or a custom one? Also, what's your *PyInstaller* version? – CristiFati Jul 28 '21 at 16:34
  • @CristiFati, my python version is 3.8.8 and my pyinstaller is 4.4. I believe it is a regular installation – Kunal M Jul 28 '21 at 16:35
  • I couldn't reproduce the error. As a workaround try: https://stackoverflow.com/questions/68428322/after-i-convert-py-to-exe-using-pyinstaller-it-throw-error. What happens if you type in your *Python* console: `import sys, os, pathlib`, `print(sys.version)`, `print(type(os.path.normpath(pathlib.PureWindowsPath("."))))`? Is the error reproducible if you remove *Kivy* from your script? Would it be a way for me to get your *.exe*? – CristiFati Jul 28 '21 at 16:52
  • When i downgrade to pyinstaller 4.3, it gives me another error. When I type that in my console it outputs: 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)] (None, None). The app wouldn't compile if I removed Kivy from the script. – Kunal M Jul 28 '21 at 17:23
  • That's a different issue. You should probably ask another question, as I'm marking this one as a duplicate. – CristiFati Jul 28 '21 at 17:49

0 Answers0