Reputation: 196
I'm creating an exe out of my simple script in command prompt with: pyinstaller --onefile --exclude-module scipy myscript.py
and when I open the .exe I get a message that says "failed to run myscript.exe script"
but the thing is the program works perfectly fine when I don't use exclude-module.. it also works perfectly fine with or without scipy (I only added it in to learn the exclude-module command)
here is my .spec file that was generated by pysinstaller:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['Simpletkinter.py'],
pathex=['C:\\Program Files (x86)\\Python36-32\\Scripts'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=['scipy'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='Simpletkinter',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False )
I plan to use the exclude option in the future so any help would be much appreciated!
Jared
Upvotes: 2
Views: 1382
Reputation: 196
Ok I found out what the problem was... You cannot use "import scipy" in your script and then later try to exclude it from pyinstaller.
I found a way around it where I only include modules inside each of my functions (which are all saved/organized in one file and used for any program I make)
now I can go and use:
pyinstaller --exclude-module scipy
which will successfully remove scipy since it is only listed inside a function which is not being used for the current script i'm trying to convert to EXE
Also I see now that python only imports once even if you tell it to import multiple times so this shouldn't slow down my programs even if I keep calling functions that import the same module multiple times
Upvotes: 2