.exe doesn't run after building from .py [duplicate] - python-3.x

This question already exists:
Can't run script when i convert .py to .exe [closed]
Closed 3 years ago.
I am beginner at python. I have just created a script which includes a Tkinter GUI application. Whenever i run it using cmd it works fine but whenever i tried to create an exe of it using pyinstaller or cx_Freeze it won't run. It just pops up console and terminates within a second.

I think your problem is that using cmd, it starts the program and does not terminate until you close the shell, and the tkinter window stays open, but when you use an exe file, it terminates after all the code is run once, so you should probably have a while loop running preferably forever until the window is closed by you.

Related

How can I open another console window

I am trying to open a new console terminal from Rust. With the help of documentation, I was capable of starting a terminal in the current terminal window, but not in another one.
For example, imagine I have one folder with two files main.py and bb.py and the following code does the thing I want
import os
os.system("start cmd /K python bb.py")
It opens a new terminal, and in this new terminal the command python bb.py is executed. How can I do this in Rust?

Not able to get control back after subprocess.call() in python

I'm creating a thread which is opening another python file using subprocess.call() which is using cmd prompt to run some commands. After running all the commands this cmd doesn't get closed and my main script keeps waiting for this thread to finish. How can I get it closed?

What exactly is main.py in python and how do I use it to create a one file executable using pyinstaller?

I am currently working on a demo project while learning python and decided to use Tkinter as a user interface for my system. After finishing on the GUI and setting up a MySQL database I tried to use pyinstaller and py2exe to create a standalone .exe but it creates only one executable for one python file and I have 6 python files.
After research I found that most people with multiple python scripts have one main.py file that runs all their scripts and they use this to create a standalone .exe. So since this seems to be the solution but my question is, what is this main.py file and how do I write it so that when I create a .exe it runs my program and still has all the scripts working?
all my python scripts
The first script that I want to execute when run my program is Login.py

Execute python executable and script inlucing full path

Im trying to create a python script with executes a series of python and sql scripts.
Some need to be executed using one python executable and some using another.
I've tried
from subprocess import call
call([r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
And
call([r"cd C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3", "pythonw.exe", r"C:\Path\to\python\file\blabla.py"])
But the script isnt being executed.
I think the problem might be "How to execute an .exe file in windows terminal including full path to it"?
Please check my code. It is working well in my side.
from subprocess import call
call([r"C:\Python38\python.exe", r"E:\python\hello.py"])
As i think, the problem is that you use pythonw.exe.
if you use pythonw.exe, you can see any log in terminal.
Pythonw is useful for running script with GUI.

How to check if a script is already running

How do you check if your script is already running to prevent it from running/opening multiple times.
I am aiming for it to either quit and allow the script to open again or stop the new one from running.
Using:
Python 3.8
Windows 10
File type .pyw
Ide: Thonny
I have looked and haven't been able to find a answer.

Resources