Reputation: 1012
How to open my .py script from anywhere on my pc directly into python idle form command prompt?
Is there any way so that i can typeidle test.py
on cmd so that it opens the test.py file in the current directory and if test.py is not available creates a new file and opens it into idle
Upvotes: 3
Views: 3354
Reputation: 1012
Create a idle.bat file containing
@echo off
{Python path}\Lib\idlelib\idle "%cd%\%1"
Where {Python path} should be replaced with the directory where python is installed.
Example:-
@echo off
C:\Python36\Lib\idlelib\idle "%cd%\%1"
Copy this idle.bat file into the python directory i.e {Python path} (C:\Python36 in case of the example)
Make sure you've add python path to environment variables
Open cmd in your folder then type
idle test.py
Upvotes: 3
Reputation: 1943
You can right click on the idle then you will can see location of it in the properties tab
Navigate to that location and call as below
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 2.7>"IDLE (Python GUI).lnk" C:\Python27\projects\ping.py
Upvotes: 3
Reputation: 19451
You can do that by adding the directory where you have installed the idle
editor the PATH
environment variable.
How to do that depends on your operating system: just search the Internet for add directory to path
plus your operating system: e.g. Windows/Ubuntu, etc.
After changing the environment variable it may be a good idea to restart your PC (to make sure that all programs use the updated version)
Upvotes: 3