ImportError: cannot import name 'storage' from 'google.cloud'
Fixes the google.cloud namespace failing to expose storage after installing google-cloud-storage. Use when from google.cloud import storage fails. Not for credential or permission errors.
TL;DR: The google.cloud namespace is shadowed, almost always by the ancient google-cloud meta-package or a duplicate install. Uninstall google-cloud (the meta-package), force-reinstall google-cloud-storage, and the import works.
ImportError: cannot import name 'storage' from 'google.cloud'Fix it
- Check for the legacy meta-package: pip show google-cloud. If present, remove it: pip uninstall google-cloud. Expected: gone.
- Reinstall the real thing: pip install --force-reinstall google-cloud-storage. Expected: clean install.
- Verify: python -c "from google.cloud import storage; print(storage.version)". Expected: a version, no traceback.
- If it still fails, check python -c "import google.cloud; print(google.cloud.path)" for a stray directory and make sure pip and python are the same interpreter (python -m pip).
When this applies
- from google.cloud import storage fails but pip shows google-cloud-storage installed.
When it doesn't
- pip does not show google-cloud-storage: install it.
- The import works but calls fail with 403: that is IAM permissions, not this.
Compatibility
- google-cloud-storage >= 1.30; Python 3.8+.
Why it happens
google-cloud-* packages share the google.cloud namespace. The retired google-cloud meta-package and hand-copied installs break namespace resolution, so Python finds google.cloud but not the storage submodule inside it.
Edge cases
- google-cloud-bigquery, pubsub, etc. hit the identical failure mode with their own submodule names; the fix is the same.
- Vendored or zipped deployments must include the namespace .pth/dist-info files.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.