How to Install loguru in Python
Python logging made (stupidly) simple
pip install loguru
What is loguru?
Python logging made (stupidly) simple
Loguru is a library which aims to bring enjoyable logging in Python.
Did you ever feel lazy about configuring a logger and used instead?... I did, yet logging is fundamental to every application and eases the process of debugging. Using Loguru you have no excuse not to use logging from the start, this is as simple as .
Also, this library is intended to make Python logging less painful by adding a bunch of useful functionalities that solve caveats of the standard loggers. Using logs in your application should be an automatism, Loguru tries to make it both pleasant and powerful.
Quick Start
Minimal example to get started with loguru:
from loguru import logger
logger.info("Starting application")
logger.warning("Something looks odd")
logger.error("Something went wrong")
# Log to a rotating file
logger.add("app.log", rotation="10 MB")
logger.info("This also writes to app.log")
Installation
pip (standard)
pip install loguru
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install loguru
pip3
pip3 install loguru
conda
conda install -c conda-forge loguru
Poetry
poetry add loguru
Dependencies
Installing loguru will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import loguru; print(loguru.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing loguru with pip.
ModuleNotFoundError: No module named 'loguru'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install loguru. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'loguru' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install loguru to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'loguru'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show loguru and upgrade with pip install --upgrade loguru.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install loguru. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user loguru
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org loguru
Recent Releases
| Version | Released |
|---|---|
0.7.3 latest |
2024-12-06 |
0.7.2 |
2023-09-11 |
0.7.1 |
2023-09-04 |
0.7.0 |
2023-04-10 |
0.6.0 |
2022-01-29 |
Manage loguru
Upgrade to latest version
pip install --upgrade loguru
Install a specific version
pip install loguru==0.7.3
Uninstall
pip uninstall loguru
Check what is installed
pip show loguru