Reputation: 21
I've done a project in python and prolog with TKINKTER and PYSWIP. When creating the executable with "pyinstaller -w --onefile main.py" it gives me an error because it is not using PYSWIP library. How can I import this package to my executable? Note: Pyswip is installed via pip
[1
Upvotes: 2
Views: 101
Reputation: 11
I had the same problem and I found out it's the libswipl.dll packaged inside with pyinstaller. Removing that .dll in the .spec file and making a new executable from that .spec seems to solve the issue.
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['Your Python Application Filepath'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
a.binaries = a.binaries - TOC([('libswipl.dll', None, None)])
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='Your Python Application Name',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Notice that I just added the
a.binaries = a.binaries - TOC([('libswipl.dll', None, None)])
To exclude that .dll
This seems to work because pyswip searches the default location of swipl (which seems to have changed because it should be swipl/ instead of pl/), then searches through the system PATH, finding the Temp folder in %APPDATA%/Local/Temp and the folder assigned for the executable you made, where it can find the .dll, but it doesn't have anything else. By excluding this, you need to have swipl installed on the device running the executable.
Upvotes: 1