Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python doesnt open #8

Open
Lauris1223 opened this issue Nov 26, 2024 · 3 comments
Open

Python doesnt open #8

Lauris1223 opened this issue Nov 26, 2024 · 3 comments

Comments

@Lauris1223
Copy link

When I click on the python file it doesnt open it just closes down right away

@Marshope
Copy link

If a Python file closes immediately after being clicked, it's likely due to quick execution without pauses. To keep the window open and view output, you can add an input() statement at the end of your script, like this:
print("Script output here")
input("Press Enter to close the window...")
This will prompt the user to press Enter before closing, allowing you to see any printed output or error messages.

@cloudsofvenus
Copy link

cloudsofvenus commented Nov 30, 2024

The main issue i had to fix was on windows and Suse Enterprise Linux was there is not any logging in place that made sense but this is purely a proof of concept. I fixed these using pyenv using Community PYCHARM on Windows 10 IOT LTSC.

Similar issue if running windows moving python2 to three on Linux is trivial windows caused more problems initially though Java is my best language.

I have submitted a pull request to fix all of these issues hopefully they will be approved.

@202301060229
Copy link

When you double-click a Python file (usually .py file) in the Windows system, but the file just flashes by and closes immediately, this is usually because the system uses the Python interpreter to execute the script by default, and the interpreter closes after the script is executed. This usually happens when the execution time of the script is very short, or when nothing is output to the console after the script is executed.
To solve this problem, you can take the following methods:
Open with IDE or text editor: you can open and edit Python files using integrated development environments (IDE) such as PyCharm, VS Code, etc., or text editors such as Notepad++, Sublime Text, and so on. These tools can not only open files, but also provide code highlighting, syntax checking and other editing functions.
Modify file association: you can change the file association setting to open it with a specific text editor when you double-click the .py file instead of executing it directly. In Windows, you can right-click the file, select "Open with", and then select a text editor to change the default opener.
Add an input prompt to the script: add a line of code input ("Press Enter to exit") at the end of the Python script, so that when the script is executed, it will wait for the user to press enter before exiting, so you can see the output of the script.
Run using the command line: navigate to the directory where the Python file is located on the command line (CMD or PowerShell), and then use the python script.py command to run the script. This way you can see the output of the script in the same window, and you can keep the window open until you have finished viewing the output.
With the above method, you can avoid the problem of closing the Python file immediately after double-clicking, and you can view the output of the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants