Python shell is open but not .py file? - python

I am using python 3.4.2 IDLE on windows.
When I open the IDLE shell and then open .py file, then it works,
but when I try to open the .py file by double cliking, it just doesn't open, or proceed anything. Looks like as if nothing has happened.
I would like to open .py file and then just press F5 to see what is going on rather than individually open all the file (I am still beginner to python, I know I can use pycharm, but at this point, just that would be good enough)

When you double click on a .py file, it will run it using the Python Interpreter. You can right-click on the file instead and choose to open it in IDLE.

Related

How to open a python file in Cmder Terminal Quicker?

I want to open a python file in cmder terminal quickly. Currently, the fastest way i know how is to navigate to the directory of the python file in cmder terminal and then run it by calling "python file.py". This is slow and cumbersome. Is there a way for me to have a file or exe, that, when i run it (or drag the program onto it), automatically makes the program run in cmder straight away.
Windows 10
Clarification: I'm using cmder terminal specifically because it supports text coloring. Windows terminal and powershell do not support this.
On windows you can go to the directory with the file in the explorer and then simply hold shift as you right click at the same time. This will open the menu and there you will have the option to use the command shell/powershell and then you don't have to navigate to the directory inside the shell anymore and can just execute the python file.
I hope that helps.
Answer: The escape codes just weren't properly configured for the windows terminals. You can get around this by using colorama's colorama.init(). It should work after that.

can't execute pyw on windows

I want to hide the console window of a python program, so I change the file extensions to "pyw", but when I open it, the python IDLE show up even though I choose open it with "pythonw.exe"
If I use "pythonw test.py" in cmd, it works.
So I want to know what's wrong with this and how to solve this, thank you.
Change the program that opens python files.
Assuming you're using Windows, right click any python file (in your case any .pyw file, not .py), properties, change Opens with to pythonw instead of IDLE
For me, I had multiple version of Python installed that was causing issues. Once I had only had one version, I applied that pythonw.exe was the default for .pyw files and it worked.

Python - Loading a source script

I am brand new to python and I'm using IDLE. However, as I learn, it is very tedious to retype an entire class over and over again at the prompt while I work out small syntax errors.
I would love to simply write a .py script in notepad++ and load it from the IDLE prompt. How is this done?
I'm using Windows not UNIX/Linux or Mac
In IDLE, Crtl+n will create a new python file that you can edit your code in. When you click F5 it will prompt you to save the file, which you can save anywhere and then will execute the file.
Each time you edit, click Ctrl+S to save and F5 to run the newly updated file.

How to run a Python program without a window?

Is it possible to make a program in Python that, when run, does not actually open any window (including command prompt)?
For example, opening the program would appear to do nothing, but in reality, the program is running in the background somewhere.
Thanks!
Are you running the python program by double clicking *.py file in Windows?
Then, rename the *.py file to *.pyw.
Run it with pythonw.exe instead of python.exe.

Start GUI application using subprocess

I am trying to open a file through python that once it is open takes you to a GUI. The link works fine when i just click on it and python seems to locate the file and open it, but the GUI doesn't appear. Please help. This is whay i have been using.
import subprocess
subprocess.Popen("C:/full/path")
I get no track back errors, but the GUI doesn't appear. Thoughts of how I can get it to appear, or what the problem might be?
Thanks
The file you're trying to 'start' is a cmd script. Use this code:
subprocess.Popen("cmd.exe /k C:\full\path\to\file.cmd")
.cmd files are not executable by themselves - you need to invoke cmd.exe to execute them. This is also what windows does when you double-click the file on the desktop.

Categories

Resources