Setting up Your Python Environment
Before we can start writing code, we need to ensure your computer is equipped with the right tools. We’ll be setting up the latest version of Python and a professional-grade editor.
1. Installing Python
Visit python.org/downloads and download the latest version for your operating system (Windows, macOS, or Linux).
Key Installation Steps:
- Windows Users: Crucially, make sure to check the box that says “Add Python to PATH” during installation. This allows you to run Python from any command prompt.
- macOS/Linux: Python often comes pre-installed, but it’s usually an older version (Python 2.x). Ensure you install Python 3.x using Homebrew (
brew install python) or the official installer.
2. Choosing an Editor
While you can write code in a simple text editor, professional developers use Integrated Development Environments (IDEs) or powerful text editors like:
- VS Code (Recommended): Free, powerful, and has the best Python extension.
- PyCharm: A dedicated Python IDE with deep internal tooling.
3. Verifying the Installation
Open your terminal or command prompt and type:
python --version
If you see Python 3.x.x, you’re ready to go!
4. Your First Virtual Environment
Learn to keep your projects organized. Virtual environments prevent different projects from interfering with each other’s dependencies.
# Create a virtual environment
python -m venv venv
# Activate it (Windows)
.\venv\Scripts\activate
# Activate it (macOS/Linux)
source venv/bin/activate
In the next lesson, we’ll write your very first line of code!