ModuleNotFoundError: No module named 'azure.storage'
Fixes environments where azure-storage-blob is installed but the azure.storage namespace is missing. Use when the import fails despite the package being present. Not for never-installed cases.
TL;DR: Same family as the azure.identity namespace issue: a legacy azure/init.py or a pip/python mismatch hides the namespace. Uninstall legacy azure packages, reinstall azure-storage-blob with python -m pip, and verify the interpreter.
ModuleNotFoundError: No module named 'azure.storage'Fix it
- Check alignment: python -m pip show azure-storage-blob and python -c "import sys; print(sys.executable)". Expected: same interpreter both sides.
- Remove legacy shadowing packages: pip uninstall azure-storage azure-mgmt-storage azure-common. Expected: no more pkgresources-style azure/init_.py.
- Reinstall: python -m pip install --force-reinstall azure-storage-blob. Expected: from azure.storage.blob import BlobServiceClient works.
- Verify in a fresh shell, not just the current one, to rule out stale PYTHONPATH.
When this applies
- pip shows azure-storage-blob but azure.storage does not import.
- Old azure-* packages are also installed.
When it doesn't
- pip does not show azure-storage-blob: install it.
- The import works but auth fails: credential problem, not this.
Compatibility
- azure-storage-blob 12.x; Python 3.8+.
Why it happens
All Azure SDK packages share the azure. namespace. One legacy package with a real init.py breaks namespace resolution for every other azure. package.
Edge cases
- The old azure-storage meta-package (2.x track) is the most common culprit; it must go before v12 resolves.
- Editable installs of local azure packages can also shadow; check pip list for -e entries.
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.