from pkg_resources import DistributionNotFound, get_distribution ModuleNotFoundError: No module named ‘pkg_resources’
This error is occurring because the pkg_resources module, which is part of the setuptools package, is not available in your Python environment. This is a common issue when using Python 3.12, as setuptools is no longer included by default. Let’s resolve this issue:
- The problem: The
drf_yasgpackage (Django REST framework Yet Another Swagger Generator) is trying to importpkg_resources, which is not available. - Solution: Install or upgrade
setuptoolsin your virtual environment.
Here are the steps to resolve this:
- Activate your virtual environment if it’s not already activated:
source /var/www/vhosts/for-gaza.com/api.for-gaza.com/venv/bin/activate2. Install or upgrade setuptools:
pip install --upgrade setuptools 
Leave a Reply