Reputation: 167
I have a working python script. I have tried converting it to .exe with Pyinstaller using all options i.e. --onefile, --onedir etc. It creates an exe file though but it doesn't run. When I run it, it just pops up and goes.
pyinstaller --onefile myscript.py
pyinstaller --onedir myscript.py
pyinstaller myscript.py
Nothing seems to be working for me. Please help! This is the error I get. Seems as if some libraries couldn't be imported
Upvotes: 0
Views: 3912
Reputation: 20302
In your cmd window enter 'pip install py2exe'.
Enter this in Python:
print("Hello There!")
from distutils.core import setup
import py2exe
setup(
console=['myscript.py'],
options = {
'py2exe' : {
'packages' : ['pandas']
}
}
)
Compile your project by tapping the F5 key.
In my example, I have this:
"C:\Users\Excel\.spyder-py3\untitled1.py"
It's not a clever name, but it serves the purpose.
In your cmd prompt, enter this: "C:\Users\Excel\.spyder-py3\untitled1.py"
You will immediately see the results in the same cmd window, and that's your validation that your program ran!
See the link below for more info.
https://null-byte.wonderhowto.com/how-to/convert-python-script-exe-0163965/
Upvotes: 1