Getting Started with Python: Windows and Linux Setup
- Published on
Python is a powerful and versatile programming language perfect for beginners and experienced programmers alike. If you want to learn Python, the first step is setting up your development environment. Here's a simple guide for both Windows and Linux users.
Windows
Download Python:
- Go to the official Python website (https://www.python.org/downloads/windows/)
- Choose the latest version of Python and download the installer for Windows.
Run the Installer:
- Open the downloaded installer and follow the prompts.
- Crucial: Check the box to "Add Python to PATH" during the installation. This lets you access Python from the command line.
Verify Installation:
- Open a command prompt (search for "cmd").
- Type
python --version
and press Enter. If successful, you'll see the installed Python version.
Linux
Most Linux distributions come with Python pre-installed, but it's often an older version. Let's make sure you have the latest:
Check Existing Version:
- Open a terminal window.
- Run
python3 --version
.
Update or Install (if necessary):
- Ubuntu/Debian: Use the apt package manager:
sudo apt-get update sudo apt-get install python3
- Fedora/CentOS: Use the yum package manager:
sudo yum install python3
- Ubuntu/Debian: Use the apt package manager:
Verify Installation:
- Run
python3 --version
in your terminal. You should see the updated version.
- Run
Code Editor/IDE
Now you need a place to write your Python code! Here are some popular choices:
- Visual Studio Code (VS Code): A versatile code editor with excellent Python support. Download from https://code.visualstudio.com/
- PyCharm: A full-featured IDE (Integrated Development Environment) for Python. Find it at https://www.jetbrains.com/pycharm/
Installing Packages (pip)
Python comes with a wealth of built-in functionality, but its real power lies in external packages. You'll use "pip," the package installer for Python.
- Example: Installing NumPy (a popular scientific computing package):
pip install numpy
Hello, World!
Let's write your first Python program:
Open your chosen code editor/IDE.
Create a new file and name it
hello.py
.Type the following code:
print("Hello, World!")
Save the file.
To run it:
- Open a terminal or command prompt.
- Navigate to the folder where you saved
hello.py
- Type
python hello.py
and press Enter.
You should see "Hello, World!" printed on your screen!
Congratulations! You've got Python running on your system and are ready to start coding.
Additional Tips
- Virtual Environments: Consider using virtual environments to isolate your projects and avoid conflicts between different package versions.
- Learn the Basics: Start with a good Python tutorial or online course to understand the fundamentals of the language.