Run in OPEN Python-Idle from Notepad++ - python

Im using a shortcut in Notepad++ to Run my Python-files directly in Python IDLE.
From the shorcut.xml, you can see how I'm using it:
<Command name="runinpython" Ctrl="no" Alt="yes" Shift="yes" Key="81">"C:\Python27\Lib\idlelib\idle.pyw" -r "$(FULL_CURRENT_PATH)"</Command>
The problem is: Every time I press Shift+Alt+Q, it opens another IDLE-Window and I'd like to only open it once and then run my .py-files in it, otherwise I have to close the IDLE windows each time after every execution.
Do you know a way to do this?
Thanks

http://mpcabd.xyz/notepad-plugin-to-run-python-scripts/ supports it
-> when running py-scripts from within Notepad++, there won't be new console-windows opened all the time, but instead the script always runs in the open cmd-window :-)

Related

VS Code had a problem in running the code

I tried to run a python program in VS Code. But my program didn't run. The terminal opened and a weird arrow was there in the terminal. This is the screenshot of that.
This is the weird arrow and the program is not running. Any ideas why this is happening and how to fix it?
Thanks in advance.
Firstly, the arrows are included in the default python IDE means that VScode ran the command to execute your code. Give your pc a restart. Now, let us check if python is working or not or VS code is having some trouble. Type the following command in cmd to execute the code-
python "$PATH"
Rember to replace $PATH to the path of the file i.e where your file is stored. For eg. I've my python files stored in D drive in a python folder, so I'll use-
python "D:\Python\Hello.py"
If this works, python is working fine and if not, try reinstalling python and check the box which says Add python to Path or Environment variables. Then open VS code try to run the program again. But click the button only once and be patient because clicking it multiple times causes execute the same command again and cause a problem. It's my personal experience. Wait 5 minutes. Not works. Don't worry, there's a problem with the run extension you are using. I'll recommend the Code runner by Jun han. I personally use it. Type this in the extension search box-
formulahendry.code-runner
Install it and then try again.
Kill the terminal, and retry. If not work, restart the VSCode.

Python IDLE 3.9.1 file not opening in windows

I had saved a python file after working on it for sometime, but now when I open it, Python 3.9.1 opens a window then immediately closes. I had done lots of work on this and don't want it to go to waste. I'm on Windows 10.
If you’re using the Open option when you right-click or you are simply double-clicking the script, the program will run and close so fast you won’t even see it.
Here are two options I use:
Open up the Command Prompt. You can easily do this by going to the address bar of your File Explorer and enter ‘cmd’. If you’re in the directory where your script is, the current working directory of the Command Prompt will be set to that. From there, run python my_script.py.
Edit your script with IDLE. If you’re using an IDE, it should be nearly the same process, but I don’t use one so I wouldn’t know. From the editor, there should be a method for running the program. In IDLE, you can just using Ctrl + F5.
Right click on it and clicken "open with". Then choose Python IDLE.
You are trying to run the file instead of editing it.
You have to right-click the file and you should the "edit with idle" option.

PyCharm running Python file always opens a new console

I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality.
I'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations.
I would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?
There is a specific option in PyCharm 2018.2+: Settings | Build, Execution, Deployment | Console | Use existing console for "Run with Python console".
Run with Python console is an option you have enabled in the Run Configuration. Disable it if you don't need a Python console after a script execution:
Hi: If you are looking for re running the code again in the same python console everytime then you have to check the respective box in the Project settings as shown in image below.
To allow only one instance to run, go to "Run" in the top bar, then "Edit Configurations...". Finally, check "Single instance only" at the right side. This will run only one instance and restart every time you run.
One console is one instance of Python being run on your system. If you want to run different variations of code within the same Python kernel, you can highlight the code you want to run and then choose the run option (Alt+Shift+F10 default).
You have an option to Rerun the program.
Simply open and navigate to currently running app with:
Alt+4 (Windows)
⌘+4 (Mac)
And then rerun it with:
Ctrl+R (Windows)
⌘+R (Mac)
Another option:
Show actions popup:
Ctrl+Shift+A (Windows)
⇧+⌘+A (Mac)
And type Rerun ..., IDE then hint you with desired action, and call it.
I think that what you are looking for is the last option in this window; check it and it should work.
Settings -> Build, Execution, Deployment -> Console

Hanging script and cmd won't close

I am trying to run a python script via cmd prompt on my work PC (Windows 7, Python 2.7). The script requires filepaths from different drives on my PC. I am correctly pulling all necessary filepaths and I press Enter to run the script but the script just hangs. The only thing that shows is a blinking underscore. I try to click the X to close the prompt but nothing happens.
I am not able to Ctrl+C out of the program either. I open up Task Manager and I am not able to End Task (nothing happens) or End Process (cmd.exe doesn't even show up in this tab). I also tried Start-->Run-->taskkill /im cmd.exe but nothing happens. The rest of my team has no problem with Python 2.7. The only way to get out of the frozen cmd is to hold down the power button. I do not want to have to keep going through this process especially since this is during work. I'm hoping someone will be able to help me out:
Any idea what's wrong with the version of Python I am using?
How am I able to kill cmd.exe so that I can continue normal work functions without having to hold down the power button and waiting 5-10 minutes to reboot my PC?
The filepaths I was pulling files from were through ClearCase directories. It turned out that I simply had to reinstall ClearCase. There must have been some configuration issue that was causing the cmd to hang and thus forcing a hard reboot. It's good to point out that I am no longer experiencing this problem and that nothing was wrong with the python scripts.

Opening Python IDE on Desktop

I am trying to open the python IDE with a specific program open on my desktop (in the shell so that I can edit it). The code I am using is:
os.system("C:\Python27\lib\idlelib\idle.py C:/Python27/lib/file_name.py")
Its working, but its opening three things:
A command line (without the actual command line)
An empty IDE
The program I was trying to open
I dont want the previous two things to open, just the third. Whats going on, how do I fix it?
Thanks,
Neil
The command window opening is an inherent part of os.system, something as simple as this should work:
C:\Python26\Lib\idlelib\idle.py "C:\file1.py"
This opens just the code you want in IDLE, without the shell. To run it in the IDLE shell (opening it in the process), simply press F5.
You can use pythonw.exe for this:
os.system('C:\Python27\pythonw.exe "<absolute path to your file here>"')

Categories