Home>
Environment

centos7
Python3.6.8

ImportError: No module named google.cloud appears even though I installed it.

The source of the error is as follows.

  

from google.cloud import speech
          from google.cloud.speech import enums
          from google.cloud.speech import types

  

from google.cloud import speech_v1 as speech
          from google.cloud.speech_v1 import enums
          from google.cloud.speech_v1 import types

The actual error is:

Error
Traceback (most recent call last):
  File "./app/trans.py", line 139, in<module>
    samplename = transcribe_gcs (args.path)
  File "./app/trans.py", line 39, in transcribe_gcs
    from google.cloud import speech
ImportError: No module named google.cloud

The following 3 lines are written on the 39th line.

from google.cloud import speech_v1 as speech
        from google.cloud.speech_v1 import enums
        from google.cloud.speech_v1 import types

Line 139 is

recog_result_text, finding_name = transcribe_gcs (args.path)


The voice analysis result is stored in recog_result_text as a return value.

What you ’ve tried

ImportError: No module named google.cloud is displayed as an import error. But

Installed related modules

gcloud 0.18.3
google 2.0.2
google-api-core 1.14.2
google-auth 1.6.3
google-cloud 0.34.0
google-cloud-core 1.0.3
google-cloud-speech 1.2.0
google-cloud-storage 1.20.0
google-cloud-texttospeech 0.5.0
google-resumable-media 0.3.3
googleapis-common-protos 1.6.0
grpc-google-cloud-speech-v1 0.8.1
grpc-google-cloud-speech-v1beta1 1.0.1

The above and linux commands are actually importing.
Furthermore, even if you actually type the code for installation, it will be natural, but you will get an error that it has already been installed like the following error.
Even if you uninstall and install again, the above error will appear.

Code that worked correctly

First of all, it works normally without errors.
Even with linux
from google.cloud import texttospeech works normally. But
from google.cloud import speech_v1 as speech
from google.cloud import speech
ImportError: No module named google.cloud
Will be rejected by the error. The same error will occur even if version is imported with _v1 removed.

Error
storage_speech_pyfile all_text Requirement already satisfied: google-cloud-storage in /usr/local/lib/python3.6/site-packages (1.19.0)
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: 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.3 in /usr/local/lib/python3.6/site-packages (from google-cloud-storage) (1.0.3)
Requirement already satisfied: six in /usr/local/lib/python3.6/site-packages (from google-resumable-media>= 0.3.1->google-cloud-storage) (1.12.0)
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: 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.3 ->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: 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.3->google-cloud-storage) (3.9.1)
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.3->google-cloud-storage) (1.6.0)
Requirement already satisfied: pytz 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.3->google-cloud-storage) (2019.2)
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.3->google-cloud-storage) (2.22.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.3->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.3->google-cloud-storage) (2.8)
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.3->google-cloud-storage) (1.25.3)
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.3->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.3->google-cloud-storage) (3.0.4)
Reference URL

https://www.tutorialfor.com/go.php?id=123983
https://stackoverflow.com/questions/51644146/python-cant-find-google-cloud-module/51651971
https://stackoverflow.com/questions/54836399/modulenotfounderror-no-module-named-google-cloud