Setting up your development environment is a fundamental step for building APIs with FastAPI. This involves ensuring you have the correct Python version and installing the necessary libraries: FastAPI itself and an ASGI server like Uvicorn to run your applications. We'll also establish a best practice by using a virtual environment to manage project dependencies cleanly.This course assumes you have Python 3.7 or later installed. FastAPI uses modern Python features like type hints and asynchronous programming, which require these recent versions. You can check your Python version by opening your terminal or command prompt and running:python --version # or sometimes python3 --versionIf you need to install or update Python, please visit the official Python website (https://www.python.org/) and follow the instructions for your operating system.Using Virtual EnvironmentsIt's highly recommended to use a virtual environment for each Python project. Virtual environments create isolated spaces where you can install specific versions of packages without affecting your global Python installation or other projects. This prevents dependency conflicts and makes your project reproducible.Python includes the venv module for creating virtual environments.Navigate to your project directory: Open your terminal and change to the directory where you want to create your FastAPI project.mkdir fastapi-ml-intro cd fastapi-ml-introCreate a virtual environment: Run the venv module, giving your environment a name (a common convention is .venv or venv).python -m venv .venv # or python3 -m venv .venvThis command creates a .venv directory containing a copy of the Python interpreter and a place to install project-specific packages.Activate the virtual environment: Activation modifies your shell's path to prioritize the environment's Python interpreter and packages.On macOS and Linux:source .venv/bin/activateOn Windows (Command Prompt):.venv\Scripts\activate.batOn Windows (PowerShell):.venv\Scripts\Activate.ps1(You might need to adjust your execution policy first: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process)Once activated, your terminal prompt will usually show the environment's name (e.g., (.venv) your-user@your-machine:...$). All subsequent pip installations will happen within this isolated environment. To deactivate, simply type deactivate.Installing FastAPI and UvicornWith your virtual environment activated, you can now install FastAPI and Uvicorn using pip, Python's package installer.FastAPI: The core web framework.Uvicorn: An ASGI (Asynchronous Server Gateway Interface) server. FastAPI is built on the ASGI standard, and Uvicorn is a fast server implementation recommended by the FastAPI creators for development and production.Install both with a single command:pip install "fastapi[all]"The [all] option is a convenience provided by FastAPI. It installs fastapi itself, uvicorn for serving, pydantic for data validation (which FastAPI heavily relies on), and several other optional dependencies that are often useful (like python-multipart for form data, jinja2 for templating, etc.). This ensures you have a comprehensive starting point.If you prefer a minimal installation, you could install them separately:pip install fastapi uvicorn pydanticHowever, using fastapi[all] is generally recommended for starting out.Verifying the InstallationTo confirm that FastAPI and Uvicorn were installed correctly, you can ask pip to show their details:pip show fastapi uvicornThis command will display information about the installed packages, including their versions. Ensure no errors are reported.Development ToolsWhile not strictly required, using a good code editor or IDE (Integrated Development Environment) will significantly improve your development experience. Options like Visual Studio Code (VS Code), PyCharm, Sublime Text, or others offer features like syntax highlighting, code completion, debugging, and terminal integration, which are very helpful when working with frameworks like FastAPI.Your development environment is now ready. You have Python, FastAPI, Uvicorn, and an isolated virtual environment. In the next section, you'll use this setup to create and run your first simple FastAPI application.