I have a python program that run without console in app.pyw file format. I converted that program to .exe file using py2exe using this script
from distutils.core import setup
import py2exe
setup(console=['app.pyw'])
now the app.exe application working fine,but app will not work without console window. I want to run my app without console window in .exe format
(I cant add a comment )
I suggest that you read the module 'distutils.core' where setup is defined.
The para 'console=['app.pyw']' might be your problem.
Here you don't need to add .pyw just edit your py2exe setup script
replace console=
by windows=
should be something like that:
from distutils.core import setup
import py2exe
setup(windows=["app.pyw"])
try setup(windows=["name"]) instead of console. When theres no GUI window to run maybe itl hide it..
Related
EDIT: I'm using the "random" library and the "os" library, could they be interfering with the file's execution?
Good morning, I'm creating a hangman game that runs all in the terminal, doesn't open any graphical window, I used pyinstaller to turn my .py file into an executable. When I run it through the command ./My_file it works normally, but if I try to run it by double clicking it doesn't open anything! Does anyone know how to solve?
I created a little application with Python3 and gtk glade, I'm using the terminal to see if I'm doing something wrong. However I want to launch the application without the terminal in the back at the end of the developement. So my question is, is there a way to do that?
You can change the file extension from .py to .pyw to make the Python script run without the terminal window. More on this here.
I was playing around with the eel module for Python - gives an opportunity to run HTML + CSS/JS with the python functionality.
Made a simple program, tried to make an executable out of it via PyInstaller.
No errors whatsoever, but when running this executable it crashes on the first line - import eel, telling - there is no module called 'bottle-websocket'.
I checked pip: eel, bottle-websocket are installed. Can't figure out what's the problem. Attachments:
main.py:
import eel
from os import path
eel.init(path.dirname(__file__) + "/web")
eel.start('main.html', block=False)
while True:
eel.sleep(10)
Error:
Picture with the error while I try to start the exe
EDIT:
PyInstaller Log
I was also having this same issue, but I finally fixed it, it was actually very very easy, first of all make sure you are using auto-py-to-exe to package your app.
After inserting necessary details (script file,, extra files etc), you would see an advanced options tab probably below, click on it to expand it, look for the hidden imports label and insert "bottle-websocket" in the input field representing the hidden imports, that's basically all you need to do
I HOPE THIS HELPS
Took me the whole day figuring out the solution, but finally, here it is:
Copy the plugin.py, server.py files from C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\lib\site-packages\bottle_websocket to C:\Users*YOUR_USERNAME*\AppData\Local\Programs\Python\Python36-32\Lib
Make sure you have this line as follows in your *.spec file generated by PyInstaller (FOR PYTHON 3.6 32bit):
datas=[('C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eel\eel.js', 'eel'), ('PATH_TO_YOUR_WEB_FOLDER', 'YOUR_WEB_FOLDER_NAME')]
3)Run this command in cmd: python C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36-32\lib\site-packages\eel\main.py HERE_SHOULD_BE_THE_PATH_TO_YOUR_WEB_FOLDER
this command will get the 'bottle-websocket' work and will make sure that it complies with the web folder and files.
I used below code to make execute of my program:
from distutils. core import *
import py2exe,sys,os
sys.argv.append('py2exe')
setup(options={'py2exe':{bundle_files':1,'compressed':True,'includes':["Tkinter",]}}'windows=['trial.py'],zipfile=None,)
It is creating single file .exe, but not executing.
same code with bundle_file 3 (without single file) is working fine.
trial.py:
import Tkinter
Tkinter.Tk()
mainloop()
Please help me to create a single .exe file for GUI program
PyInstaller is a much easier option that can be used from the console. Just pip install pyinstaller, enter your program's directory, and pyinstaller yourscript.py.
I am confused that you say trial.py is working fine when I get an error on my machine. mainloop() needs to be replaced by Tkinter.mainloop().
I have small program made in python with selenium, and now I'm trying to make an .exe with py2exe.. I get the exe but when I run it, terminal just pops up for split second then it terminates.
I tried to run .exe in cmd and It says that there is no such file as webdriver_prefs.json
Here is the setup.py I have:
from distutils.core import setup
import py2exe
setup(console=['file_name.py'])
Any input on how to resolve this is welcome.
Cheers.