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 }}
This repository was archived by the owner on May 29, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 29, 2026. It is now read-only.
Import fails on Python 3.12 in virtualenv, pkg_resources not installed by default #275
/private/tmp/workspace/.py311/lib/python3.11/site-packages/google/__init__.py:17: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
__import__('pkg_resources').declare_namespace(__name__)
/private/tmp/workspace/.py311/lib/python3.11/site-packages/google/__init__.py:17: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
__import__('pkg_resources').declare_namespace(__name__)
pkg_resources is no longer installed in a virtualenv in Python 3.12, so you get an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/workspace/.py312/lib/python3.12/site-packages/google/__init__.py", line 17, in <module>
__import__('pkg_resources').declare_namespace(__name__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pkg_resources'
The fix is to install setuptools, then you just get all the warnings again:
/private/tmp/workspace/.py312/lib/python3.12/site-packages/google/__init__.py:17: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
__import__('pkg_resources').declare_namespace(__name__)
/private/tmp/workspace/.py312/lib/python3.12/site-packages/google/__init__.py:17: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
__import__('pkg_resources').declare_namespace(__name__)
changed the title [-]Import fails on Python 3.12, pkg_resources removed[/-][+]Import fails on Python 3.12 in virtualenv, pkg_resources not installed by default[/+]on May 23, 2024
The error is because pkg_resources is no longer installed by default in a virtualenv. Installing setuptools fixes the issue, but can cause problems if you are not in a virtualenv. I've updated the issue to be more precise.
The issue would be fixed by no longer declaring a namespace, as suggested in the links in the DeprecationWarning.
Activity
[-]Import fails on Python 3.12, pkg_resources removed[/-][+]Import fails on Python 3.12 in virtualenv, pkg_resources not installed by default[/+]jwhitlock commentedon May 23, 2024
The error is because
pkg_resourcesis no longer installed by default in a virtualenv. Installingsetuptoolsfixes the issue, but can cause problems if you are not in a virtualenv. I've updated the issue to be more precise.The issue would be fixed by no longer declaring a namespace, as suggested in the links in the
DeprecationWarning.