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
/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__)
The text was updated successfully, but these errors were encountered:
jwhitlock
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
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.
If you are running a virtualenv with Python 3.11 with warnings enabled, you get a deprecation warning. On macOS Sonoma 14.5, with
pyenv
:pkg_resources
is no longer installed in a virtualenv in Python 3.12, so you get an error:The fix is to install
setuptools
, then you just get all the warnings again:.py312/bin/python3.12 -m pip install setuptools .py312/bin/python3.12 -Wall -c "import google.cloud.sqlcommenter"
The text was updated successfully, but these errors were encountered: