How To Set Up Python On Windows, Linux, Or Mac, and Run Your First Python Program?

Here are the steps on how to set up Python on Windows, Linux, or Mac, and run your first Python program.

1. Download Python

To install Python, first, you need to download the latest version of Python from the official Python website.

2. Set up Python on your computer

  • If you are on a Windows computer, you may need to add Python to your PATH environment variable. This will allow you to run Python programs from any directory.
  • If you are on a Linux or Mac computer, Python is already included in the default installation. However, you may want to upgrade to the latest version. You can run the command python –version to check the installed python version. If it says:
-bash: python: command not found

then run the command sudo apt install python and it should install the python for you in Linux.

  • There are many different IDEs (Integrated Development Environments) that you can use to write Python code. Some popular IDEs include PyCharm, Visual Studio Code, and Sublime Text.

3. Write and execute the First Python Program

  • Create a new text file. Save the file with a .py extension.
  • Write your Python code. You can start by writing a simple print statement, such as:
print("Hello, world!")
  • Save the file and run it. To run your Python program, open a command prompt or terminal window and navigate to the directory where you saved the file. Then, type the following command:
python filename.py

This will run your Python program and print “Hello, world!” to the console. Congratulations, you just did the Python setup in your local development environment and ran your first Python program. (y)

Further Readings

Check out our other blogs on Python Basics in this tutorial series.

Feel free to share your thoughts on this topic in the comments section below 👇 We would be happy to hear and discuss the same 🙂

Spread the word!
0Shares

Leave a comment

Your email address will not be published. Required fields are marked *