Horje
Open and Run Python Files in the Terminal

The Linux terminal offers a powerful environment for working with Python files, providing developers with efficient ways to open, edit, and run Python scripts directly from the command line.

Open and Run Python Files in the Linux Terminal

In this article, we’ll explore various techniques and commands for handling Python files in the Linux terminal, empowering developers to streamline their workflow and enhance productivity.

Steps to Open, Edit, and Run Python Files in the Terminal

1. Open the Ubuntu Terminal

2. Use the cd command to change the present working directory to the directory in which the Python program file is saved or in which you want to create the program file.

cd Documents/Programs/
changing present working directory using cd command in Ubuntu

changing the present working directory using the cd command in Ubuntu

3. Use the vim command to open/create the file. It will open the editor where you can write the code.

vim hello.py
Screenshot-from-2024-02-03-04-14-01

Open hello.py in Vim

Here, you can learn to use the basic commands of Vim which will help you to comfortably write you code. to save and exit use the following step:

  1. Press ESC
  2. Press :wq
  3. This will save and quit the VIM Editor.
Screenshot-from-2024-02-03-04-15-58

writing the Python code

4. After saving the file run the Python program by using the following command.

python3 hello.py
Screenshot-from-2024-02-03-04-26-21

run the Python program




Reffered: https://www.geeksforgeeks.org


Linux Unix

Related
How to Install Tor Browser on Kali Linux? [2024] How to Install Tor Browser on Kali Linux? [2024]
Linux System Monitoring Commands and Tools Linux System Monitoring Commands and Tools
How To Install Poweriso On Kali Linux How To Install Poweriso On Kali Linux
Bash Program to Check Whether the Given String is a Palindrome or Not Bash Program to Check Whether the Given String is a Palindrome or Not
How To Install Telegram-Cli On Linux? How To Install Telegram-Cli On Linux?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
9