You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RFE: Replace use of pkg_resources with importlib.metadata #861
[tkloczko@devel-g2v SRPMS]$ rpm -ql python-babel | grep py$ | xargs grep pkg_resources/usr/lib/python3.8/site-packages/babel/messages/checkers.py: from pkg_resources import working_set/usr/lib/python3.8/site-packages/babel/messages/checkers.py: # if pkg_resources is not available or no usable egg-info was found/usr/lib/python3.8/site-packages/babel/messages/extract.py: from pkg_resources import working_set/usr/lib/python3.8/site-packages/babel/messages/extract.py: # if pkg_resources is not available or no usable egg-info was found
I start to see deprecation warnings in some unit test suites:
babel/messages/checkers.py:160: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import working_set
gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.
I also get the error ValueError: Unknown extraction method 'jinja2'. Installing setuptools via pip install setuptools doesn't solve this problem for me. I have tried it on MacOS 15.1 with Python 3.9 and ArchLinux with Python 3.12.
Edit: I also tried to install setuptools with brew install python-setuptools (Mac) respectively sudo pacman -S python-setuptools (Linux), but that also doesn't help.
Edit 2: I have found a workaround. Instead of directly using pybabel, I now use ./venv/bin/pybabel, which is working fine. :)
I was also running into the error ValueError: Unknown extraction method 'jinja2' in an AlmaLinux 9 container within a Python 3.9 environment. Trying all the workarounds mentioned above did not work, but I found that specifying jinja2 as an extractor in the project's pybabel.ini file did the trick, so I'm including the example here just in case it might help someone else:
Activity
kloczek commentedon Apr 22, 2022
In this case if babel sphinx extension is used in copy.py in some cases it casues effect described in
setuptoolsticket pypa/setuptools#3279azmeuk commentedon Dec 24, 2023
I start to see deprecation warnings in some unit test suites:
j123b567 commentedon Jul 2, 2024
It is really bad because pybabel essentially does not work with python 3.12 with third party extractors.
ValueError: Unknown extraction method 'jinja2'With python 3.11, it works ok.
cclauss commentedon Jul 3, 2024
Can this be solved on Python >= 3.12 by doing
pip install setuptools?https://docs.python.org/3/whatsnew/3.12.html
j123b567 commentedon Jul 3, 2024
@cclauss thank you. It works, so it is good workaround for now.
We are working on a patch to introduce fallback to importlib.metadata
jhemmje commentedon Nov 8, 2024
I also get the error
ValueError: Unknown extraction method 'jinja2'. Installing setuptools viapip install setuptoolsdoesn't solve this problem for me. I have tried it on MacOS 15.1 with Python 3.9 and ArchLinux with Python 3.12.Edit: I also tried to install setuptools with
brew install python-setuptools(Mac) respectivelysudo pacman -S python-setuptools(Linux), but that also doesn't help.Edit 2: I have found a workaround. Instead of directly using
pybabel, I now use./venv/bin/pybabel, which is working fine. :)jlc3p commentedon Feb 11, 2026
I was also running into the error
ValueError: Unknown extraction method 'jinja2'in an AlmaLinux 9 container within a Python 3.9 environment. Trying all the workarounds mentioned above did not work, but I found that specifyingjinja2as an extractor in the project'spybabel.inifile did the trick, so I'm including the example here just in case it might help someone else:akx commentedon Sep 29, 2026
I think this is resolved by #1102 (released in Babel 2.16.0 in 2024).