Resources mentioned in this lesson:
Setting Up Loguru
00:00
In this video, you’ll learn how to install loguru so that you can start using it. loguru is available on the Python Package Index, so you can install it with pip.
00:10
Let’s see how. Open a terminal or command prompt. We’re going to use the python command -m to indicate that we want to use the built-in venv module, and we want to create a virtual environment called venv as well.
00:32
So it looks like it didn’t do anything, but when we do ls and Enter, we see that it created a venv folder that wasn’t there before.
00:42
A virtual environment allows you to manage dependencies separately for different projects. This prevents dependency conflicts and it keeps your setup clean. The command you just used created a virtual environment called venv.
00:57
Inside this folder, we’re going to find a Scripts folder, and then inside of it an activate script. We’re going to use that to activate our virtual environment. So you see that this venv in green appeared at the left side of the prompt.
01:15
At this point, you know that you’re inside a virtual environment, so we’re going to use python -m pip to install loguru.
01:33
To verify that the installation was successful, we’re going to start a Python interactive session by running python and Enter. And now we’re going to import loguru.
01:45
If the import runs without errors on your machine, congratulations, then you’ve successfully installed loguru. So now that loguru is installed, let’s pause for a second before we write any code. There are a couple of important things about how loguru works that are worth understanding up front.
02:04
First, loguru uses a single logger instance. Unlike Python’s built-in logging module, you don’t need to create or configure multiple loggers.
02:15
You just import the pre-configured logger object and you use it everywhere.
02:20
Secondly, by default, loguru already logs to standard error with a readable format, so you can start logging immediately without having to set anything up.
02:31
That’s really all there is to know before getting started. In the next lesson, you’ll start using loguru for real. You’ll go through the basic logging operations.
Become a Member to join the conversation.
