Google-cloud-python: ImportError: No module named google.cloud.storage

Created on 13 May 2018  路  8Comments  路  Source: googleapis/google-cloud-python

I have read and implemented several solution to fix this issue on my local machine, and all resulted in the same error response. Now I am executing my code in GOOGLE CLOUD SHELL, which is suppose to have google-cloud pre-install, yet I am still receiving the same errors. PLEASE HELP!!!

python version - python2.7

this is the import script

from google.cloud import storage

this is the traceback error

Traceback (most recent call last):
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/mitchkojelegance/lekoj/main.py", line 3, in <module>
    from google.cloud import storage
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1148, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named google.cloud.storage
question storage packaging

Most helpful comment

@le-koj You need to install google-cloud-storage into your Python environment:

$ pip install google-cloud-storage

All 8 comments

@le-koj You need to install google-cloud-storage into your Python environment:

$ pip install google-cloud-storage

Perfect!

Not working for me

depending on how your pip is setup, you might need to do

pip3  install google-cloud-storage

or

pip3  install --user google-cloud-storage

I tried all command below but it DIDNT work it.

env
linux centos7
python3.6.8

pip install google-cloud-storage
pip3  install google-cloud-storage
pip3  install --user google-cloud-storage

target code

from google.cloud import speech_v1 as speech
or
from google.cloud import speech

error
from google.cloud import storage
ImportError: No module named google.cloud

Requirement already satisfied: google-cloud-storage in /home/django/.local/lib/python3.6/site-packages (1.18.0)
Requirement already satisfied: google-auth>=1.2.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-storage) (1.6.3)
Requirement already satisfied: google-cloud-core<2.0dev,>=1.0.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-storage) (1.0.3)
Requirement already satisfied: google-resumable-media>=0.3.1 in /usr/local/lib/python3.6/site-packages (from google-cloud-storage) (0.3.3)
Requirement already satisfied: cachetools>=2.0.0 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.2.0->google-cloud-storage) (3.1.1)
Requirement already satisfied: rsa>=3.1.4 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.2.0->google-cloud-storage) (4.0)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.2.0->google-cloud-storage) (1.12.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.2.0->google-cloud-storage) (0.2.6)
Requirement already satisfied: google-api-core<2.0.0dev,>=1.14.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (1.14.2)
Requirement already satisfied: pyasn1>=0.1.3 in /usr/local/lib/python3.6/site-packages (from rsa>=3.1.4->google-auth>=1.2.0->google-cloud-storage) (0.4.7)
Requirement already satisfied: pytz in /home/django/.local/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (2018.3)
Requirement already satisfied: protobuf>=3.4.0 in /usr/local/lib64/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (3.9.1)
Requirement already satisfied: requests<3.0.0dev,>=2.18.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (2.22.0)
Requirement already satisfied: googleapis-common-protos<2.0dev,>=1.6.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (1.6.0)
Requirement already satisfied: setuptools>=34.0.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (41.2.0)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (2019.9.11)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage) (1.25.3)

it did not work for me too.
I can find these packages, but python can not import them!

ls /opt/anaconda3/envs/zfish/lib/python3.7/site-packages/google*
google/                                    googleapis_common_protos-1.51.0-py3.7.egg  google_cloud-0.34.0.dist-info/             google_resumable_media-0.5.0-py3.7.egg/
google-2.0.3.dist-info/                    google_apitools-0.5.30.dist-info/          google_cloud_core-1.3.0-py3.7.egg/         googlesearch/
google_api_core-1.16.0-py3.7.egg/          google_auth-1.13.1-py3.7.egg/              google_cloud_storage-1.27.0-py3.7.egg/   

Also not working for me.
pip3 reports it is installed, import throws exception
Did work find on Windows 10, not working on ARM linux.

What helped me solve the issue:

  1. List all google related pip packages with pip freeze | grep google
  2. Remove all of them with pip uninstall {package_name}
  3. Reinstall the packages from scratch
Was this page helpful?
0 / 5 - 0 ratings