Repository navigation
Closed
Labels
externalThis issue is blocked on a bug with the actual product.This issue is blocked on a bug with the actual product.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: blockedResolving the issue is dependent on other work.Resolving the issue is dependent on other work.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
We haven't recently started to see import issues with packages that use google-api-core in openSUSE Tumbleweed.
For example, the package celery fails to import google.cloud [1]:
[ 21s] ==================================== ERRORS ====================================
[ 21s] _________________ ERROR collecting t/unit/backends/test_gcs.py _________________
[ 21s] ImportError while importing test module '/home/abuild/rpmbuild/BUILD/python-celery-test-5.5.3-build/celery-5.5.3/t/unit/backends/test_gcs.py'.
[ 21s] Hint: make sure your test modules/packages have valid Python names.
[ 21s] Traceback:
[ 21s] /usr/lib64/python3.11/importlib/__init__.py:126: in import_module
[ 21s] return _bootstrap._gcd_import(name[level:], package, level)
[ 21s] t/unit/backends/test_gcs.py:5: in <module>
[ 21s] from google.cloud.exceptions import NotFound
[ 21s] E ModuleNotFoundError: No module named 'google.cloud'
[ 21s] =============================== warnings summary ===============================
And indeed that does not work on a test system:
glaubitz@suse-laptop:~> python3
Python 3.13.3 (main, Apr 11 2025, 19:56:42) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.cloud
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
import google.cloud
ModuleNotFoundError: No module named 'google.cloud'
>>>
glaubitz@suse-laptop:~> rpm -q python313-google-api-core
python313-google-api-core-2.25.1-0.noarch
glaubitz@suse-laptop:~> ls -ld /usr/lib/python3.13/site-packages/google/cloud
drwxr-xr-x 4 root root 4096 May 14 11:53 /usr/lib/python3.13/site-packages/google/cloud
glaubitz@suse-laptop:~>
It seems that I am missing something here but I'm not sure what.
Any suggestions?
Metadata
Metadata
Assignees
Labels
externalThis issue is blocked on a bug with the actual product.This issue is blocked on a bug with the actual product.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: blockedResolving the issue is dependent on other work.Resolving the issue is dependent on other work.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
glaubitz commentedon Jun 16, 2025
The problem is that there is a
googlename space both in/usr/lib64/python3.13/site-packages/googleand/usr/lib/python3.13/site-packages/google, so it affects distributions which are not using canonical Python search paths per architecture.On Debian and Ubuntu, which both have such canonical architecture-dependent search paths thanks to MultiArch, the problem does not occur.
parthea commentedon Jun 16, 2025
Hi @glaubitz,
Please could you provide detailed steps to build this image, or reproduce the problem?
In the build log, I see the following error however the code
pkg_resources.declare_namespace('google')in the stack trace was removed from__init__.pyin googleapis/python-api-core#561Please could you also share the output of
pip freezewithin the test environment? It's possible that an old version of a dependency is used, which still has code ingoogle/__init__.py.glaubitz commentedon Jun 16, 2025
Thanks for the quick reply!
This is on stock openSUSE Tumbleweed. The issue affects 64-bit targets only.
See attached. Did you see my other message which showed how to workaround the issue?
pip_freeze.txt
parthea commentedon Jun 16, 2025
In the
pip_freeze.txtfile I don't seegoogle-cloud-core. Please can you try installing that package in the environment usingpip install google-cloud-core?This import statement is part of
google-cloud-corerather thangoogle-api-core.google-cloud-coresource lives here.google-cloud-coreis only used in a fewgoogle-cloud-packages as per this search.glaubitz commentedon Jun 16, 2025
This not the problem though as I stated above but sure:
Yes, I'm aware of this. But that's not the source of the problem. The problem is that the
googlenamespace exists both in the 64-bit and 32-bit site-packages search path.parthea commentedon Jun 16, 2025
Is it possible to create a python virtual environment? Does that solve the issue?
Using this docker image, the import
from google.cloud.exceptions import NotFoundsucceeds. Is it possible to create a reproduction with docker?glaubitz commentedon Jun 16, 2025
A Python environment does unfortunately not address the distribution problem.
My intention for this bug report was not to get a user problem solved, but to figure out why
google.apisuddenly no longer can be imported and it seems that the problem in general is that the Python interpreter cannot handle namespaces that exist in two different search paths.parthea commentedon Jun 16, 2025
google.apiwas not mentioned in this issue before the last comment. I also don't seegoogle.apiin the log file. If the issue is easily reproducible, would you be willing to create a Dockerfile that demonstrates the problem using this as a starting point?glaubitz commentedon Jun 16, 2025
It doesn't matter what namespace I'm trying to import. It affects all of them. This is neither specific to
google.apinorgoogle.cloud.As I have mentioned before, the problem is that there is a
googlenamespace in both/usr/lib64/python3.13/site-packagesand/usr/lib/python3.13/site-packagesand temporarily renaming the latter fromgoogleto anything else fixes the import problem.The only reason I reported this issue here is that it worked in the past and I don't think the Python interpreter has introduced breaking changes to it's search path mechanism.
parthea commentedon Jun 16, 2025
Is there a specific version older version of
google-api-coreorgoogle-cloud-corethat works? Regrettably, without a minimal reproduction , or a specific version of some package that introduced some change in behavior, it's going to be difficult to move forward on this issue. If possible, it could be helpful to re-run the last build that succeeded, and change one thing at a time until the specific package/version where things started failing can be identified.ohmayr commentedon Jun 20, 2025
@glaubitz
Bash script to reproduce the error:
Output Error:
Steps to reproduce:
Notes:
I've verified that the earliest snapshot which introduces this import error is
20250604. Updating the snapshot to20250602and re-running the script does not produce this error. Both these snapshots (up until20250608) have an identical version ofgoogle-api-corewhich isv2.24.2. This means thatgoogle-api-coreisn't the direct cause of this issue. The problem is likely in the environment in which it is run. It could be a direct dependency or a core system library.Search for
google-api-corehere to verify the versions:20250602: http://download.opensuse.org/history/20250602/tumbleweed/repo/oss/noarch/
20250604: http://download.opensuse.org/history/20250604/tumbleweed/repo/oss/noarch/
Next steps:
File a new bug for Tumbleweed here https://bugzilla.opensuse.org/.
I hope this helps. Let us know if you have any questions.
glaubitz commentedon Jun 24, 2025
Thanks a lot, this is very useful. There is already an open openSUSE bug which is currently assigned to the
python-google-api-corepackage, see: https://bugzilla.suse.com/show_bug.cgi?id=1244918glaubitz commentedon Jun 24, 2025
The problem is
python-protobuf. Downgrading to version 5.29.3 fixes the problem.parthea commentedon Jan 12, 2026
Transferring to google-cloud-python as the code for python-api-core will be migrated there in 1-3 weeks.
parthea commentedon Apr 28, 2026
Closing as obsolete as https://bugzilla.suse.com/show_bug.cgi?id=1244918 is fixed