

We can also run python scripts from within the IDLE by clicking on File > New File from the menu. The default IDLE provided by Python during installation is an interactive shell by default. There are a lot of python-friendly IDEs now a days that provide easy way of running python files.

If the terminal/command prompt/anaconda prompt is open in the same directory, you can just replace the filepath by filename as shown below In that case, I can run the following command This is clearly not the folder where we have stored our sample.py file. Now if we open the Anaconda prompt on the windows machine, the default path will be C:\Users\Username. For example, consider a file called 'sample.py' stored in E:\ProjectPro folder on a windows machine which contains the necessary python code.

In order to do that, you have to create a file with a '.py' extension anywhere in your computer. The command to run a python file is fairly simple The other most common way of running python scripts is by running them as a. You can quit the interactive shell using the quit() function or exit() function You can easily use any python functions and hit enter once you are done. This will open an interactive session like below. If you have installed Anaconda, Anaconda navigator is the best choice. Once the installation process is complete on your system, then the next step is to open the terminal(In case of Mac/Linux) or the Command prompt(In case of Windows).
