Import Error: "px" not found using pyinstaller

Viewed 106

I'm trying to create a standalone executable with pyinstaller.

I use a win10 venv using vmware, where I've got a clean python version installed.

I can execute my .py file as usual but if I try to run my .exe file I get the following error:

ttps://i.stack.imgur.com/FRdmI.png

So far I've tried:

  1. importing px manually in my script (import px)
  2. using the command pyinstaller servicetool.spec --hidden-import=px instead of pyinstaller servicetool.spec.
  3. using pip install px, which says its already installed.
  4. to add hiddenimports=['px'] to my .spec file, attached here


block_cipher = None


a = Analysis(['C:\\Users\\philipp\\Desktop\\Servicetool\\Servicetool.py'],
             pathex=['C:\\Users\\philipp\\Desktop\\Servicetool'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
a.datas += [('Favicon.ico', 'C:\\Users\\philipp\\Desktop\\Servicetool\\Favicon.ico', 'DATA')]
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='servicetool',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False,
      icon='C:\\Users\\philipp\\Desktop\\Servicetool\\Favicon.ico')

Sorry for my bad english, I'm new to programming so please ask if you need some more information. Thanks for your help and best regards

1 Answers

The Answer was relative simple... I just had to found out which library caused the problem, and then I had to copy some missing .dll into the folder my .py, and my .spec file were. in my case it was the module pypxlib, which imported px cause of that, I:

  1. had to copy pxlib.dll from the pip source folder into my folder.
  2. edit my .spec file (datas):
a = Analysis(['servicetool.py'],
             pathex=['C:\\Users\\Philipp\\Desktop\\Servicetool'],
             binaries=[],
             datas=[('pxlib.dll', '.')],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)```
Related