Table of Contents
- Introduction
- Installing Python on Your System
- Windows Installation
- macOS Installation
- Linux Installation
- Setting Up Visual Studio Code (VSCode) for Python
- Installing PyCharm IDE
- Installing Jupyter Notebook
- Verifying Your Development Environment
- Best Practices for Setting Up Python Development
- Final Thoughts
Introduction
Before diving into coding with Python, it is crucial to set up your development environment correctly. Having a well-structured setup not only improves productivity but also prevents common pitfalls for beginners and professionals alike. In this module, we will cover the installation of Python itself, along with essential tools such as Visual Studio Code (VSCode), PyCharm, and Jupyter Notebook. These tools together will give you the flexibility to build anything from simple scripts to full-fledged machine learning models.
Installing Python on Your System
Python needs to be installed locally to develop, run, and manage projects efficiently. Python 3 is the current standard, and most modern libraries and frameworks are built for Python 3.x versions.
Windows Installation
- Download Python:
- Visit the official Python website: https://www.python.org/downloads/.
- Click on the latest Python 3 release for Windows.
- Run the Installer:
- Open the downloaded
.exe
file. - Important: Check the box that says “Add Python 3.x to PATH” at the beginning of the installation wizard.
- Click on Install Now for a quick installation.
- Open the downloaded
- Verify Installation:
- Open Command Prompt and type:
python --version
- You should see the installed version number.
- Open Command Prompt and type:
- Install pip (Python Package Installer):
- pip usually comes bundled with Python 3.x. Verify by typing:
pip --version
- pip usually comes bundled with Python 3.x. Verify by typing:
macOS Installation
- Using Homebrew (Recommended):
- Install Homebrew if it’s not already installed:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Then, install Python:
brew install python
- Install Homebrew if it’s not already installed:
- Verify Installation:
- Open Terminal and type:
python3 --version
- Open Terminal and type:
Linux Installation
- Using apt for Ubuntu/Debian:
sudo apt update sudo apt install python3 python3-pip
- Verify Installation:
python3 --version
Most Linux distributions already come with Python pre-installed, but you may still want to install a newer version.
Setting Up Visual Studio Code (VSCode) for Python
Visual Studio Code is one of the most popular code editors used for Python development. It is lightweight, highly customizable, and has extensive extensions support.
- Download and Install VSCode:
- Go to https://code.visualstudio.com/ and download the appropriate version for your OS.
- Install the Python Extension:
- Open VSCode.
- Go to Extensions (sidebar or
Ctrl+Shift+X
). - Search for Python and install the official Microsoft extension.
- Configure Python Interpreter:
- Open the command palette (
Ctrl+Shift+P
). - Search for Python: Select Interpreter.
- Choose the correct Python 3 interpreter installed earlier.
- Open the command palette (
- Install Additional Useful Extensions (optional):
- Pylance (for type checking and IntelliSense)
- Jupyter (to open
.ipynb
files inside VSCode) - GitLens (for Git version control integration)
Installing PyCharm IDE
PyCharm is a full-featured Integrated Development Environment (IDE) specifically designed for Python development. It provides out-of-the-box support for project management, debugging, testing, and frameworks.
- Download PyCharm:
- Choose Edition:
- Community Edition: Free and suitable for most use cases.
- Professional Edition: Paid version with advanced web development and database support.
- Install PyCharm:
- Run the installer and follow the prompts.
- Add PyCharm to the system path if prompted.
- Set Up Python Interpreter:
- Upon creating a new project, select the Python interpreter you installed earlier.
Installing Jupyter Notebook
Jupyter Notebook is essential for data science, machine learning, and any development where you need inline visualizations, notes, and step-by-step execution.
Installing via pip
- Open Terminal or Command Prompt:
pip install notebook
- Launch Jupyter Notebook:
jupyter notebook
- This will open the Jupyter Notebook interface in your default web browser.
Installing via Anaconda (Optional)
Anaconda is a distribution that comes pre-packaged with Jupyter and many other data science libraries.
- Download and Install Anaconda:
- Launch Jupyter Notebook:
- Open Anaconda Navigator and click on the Jupyter Notebook launch button.
Verifying Your Development Environment
To make sure everything is set up properly:
- Python:
python --version
- pip:
pip --version
- VSCode:
- Open a
.py
file and see if the interpreter is correctly detected.
- Open a
- PyCharm:
- Create a “Hello World” project and run it.
- Jupyter:
- Open a notebook and create a simple cell:
print("Hello, Jupyter!")
- Open a notebook and create a simple cell:
If all the above steps work, your environment is fully functional.
Best Practices for Setting Up Python Development
- Virtual Environments: Always use
venv
orvirtualenv
for project-specific dependencies. - Linting and Formatting: Set up tools like
flake8
andblack
to maintain code quality. - Version Control: Install Git and connect it to VSCode or PyCharm for project version control.
- Extensions and Plugins: Regularly update your Python-related extensions for better performance.
- Python Path Issues: Ensure that your system’s PATH variable is correctly set up to avoid issues in finding Python binaries.
Final Thoughts
Setting up a robust Python development environment is the first major step toward becoming an efficient and productive developer. Whether you are targeting web development, machine learning, or automation, a correctly configured setup with Python, VSCode, PyCharm, and Jupyter Notebook ensures smooth workflows and minimal frustration. In the next module, we will start writing our first Python programs and explore the basic syntax and structure of the language.