Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Setting Up the Development Environment

To learn more about the concepts in this lesson, you can check out:

00:00 Set Up the Development Environment. The first practical step is creating a virtual environment for the project. A virtual environment provides an isolated Python interpreter and a space to install your project’s dependencies. For more on virtual environments, see this Real Python course. To start, go ahead and create the project’s root directory, called rpchecker_project/.

00:28 Then move to this directory and run the following commands on your system’s command line or terminal. Here is creating and activating the virtual environment using Windows,

00:51 and here’s creating and activating the virtual environment on Linux or macOS.

01:04 In both of these, the first command creates a fully functional Python virtual environment called venv inside the project’s root directory. The second command, which is the difference between Windows or macOS, activates the environment.

01:20 Now run the following command to install the project’s dependencies with pip, the standard Python package manager.

01:30 With this command, you install aiohttp into your virtual environment. You’ll use this third-party library along with Python’s async features in the app. Note that in this course, Python 3.10 is being used alongside aiohttp 3.8.1. In this course, any code that’s executed in Python will be shown using the BPython REPL, which provides a number of improvements over the standard Python one, including color coding. However, all of the code that you see running will work in the standard Python intepreter, which you can access by typing python at your command prompt.

02:11 Python is surprisingly flexible when it comes to structuring applications, so you may find pretty different structures from project to project. However, small installable Python projects typically have a single package, which is often named after the project itself.

02:27 Following this practice, you can organize your app using the directory structure that’s seen on screen. You can use any name for this project and its main package. In this course, the project will be named rpchecker as a combination of Real Python and checker, which points out the app’s main functionality.

02:46 The README.md file will contain the project’s description and instructions for installing and running the application. Adding a README file to your project is a best practice in programming, especially if you’re planning to release the project as an open source solution.

03:02 To learn more about writing good README files, check out How to Write a Great README File for Your GitHub Project at the link seen on-screen.

03:11 The requirements.txt file will hold the list of your project’s external dependencies. In this case, you only need the aiohttp library, because the rest of the tools and modules that you’ll use are available out of the box in Python’s standard library.

03:26 You can use this file to automatically reproduce the appropriate Python virtual environment for your app using pip, the standard Python package manager.

03:37 You can create requirements.txt by using the output from pip as seen on-screen.

03:49 Note that you won’t be adding content to the README.md file in this course, but it is included in the course materials, which you can download inside the rpchecker/ directory. You have the following files: __init__.py enables rpchecker as a Python package, __main__.py works as an entry-point script for the app, checker.py provides the application’s core functionalities, and cli.py contains a command-line interface for the application.

04:23 You can create these as empty files from the command line in Windows

04:53 or in macOS and Linux.

05:10 Now that everything is in place, you can start writing code. This is what you’ll be doing in the next part of the course, where you’ll be creating the core functionality of the project: checking whether a site is online or not.

Become a Member to join the conversation.