Search code examples
pythonwindowspython-idle

Python IDLE from cmd


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


Solution

  • 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