简体   繁体   English

ModuleNotFoundError:没有名为“google.cloud”的模块

[英]ModuleNotFoundError: No module named 'google.cloud'

I'm looking to use the Google "cloud text to speech" api, and I'm having the common problem of the module not being found.我正在寻找使用谷歌“云文本到语音”api,但我遇到了找不到模块的常见问题。 I've tried the solutions that most people have, only problem being that I use windows and most of the solutions are for mac or Linux (although this shouldn't be that big of an issue).我已经尝试了大多数人拥有的解决方案,唯一的问题是我使用的是 Windows,而且大多数解决方案都适用于 mac 或 Linux(尽管这应该不是什么大问题)。

I ran the 'pip list' on the command line and here's what it returned:我在命令行上运行了“pip list”,这是它返回的内容:

google                    2.0.1
google-api-core           1.7.0
google-auth               1.6.3
google-cloud              0.34.0
google-cloud-texttospeech 0.4.0
googleapis-common-protos  1.5.8

And if this helps, this is what I have been running on the import statement ( this is also taken from google's tutorial )如果这有帮助,这就是我在 import 语句上运行的内容(这也取自 google 的教程

>> from google.cloud import texttospeech

from google.cloud import texttospeech
ModuleNotFoundError: No module named 'google.cloud'

Any solutions?任何解决方案?

ModuleNotFoundError: No module named 'google.cloud' ModuleNotFoundError:没有名为“google.cloud”的模块

To solve this problem:要解决这个问题:

  1. Remove google-cloud: pip uninstall google-cloud删除谷歌云: pip uninstall google-cloud
  2. Reinstall with update google-cloud-texttospeech: pip install --upgrade google-cloud-texttospeech使用更新 google-cloud-texttospeech 重新安装: pip install --upgrade google-cloud-texttospeech --upgrade pip install --upgrade google-cloud-texttospeech

The library google-cloud is deprecated.google-cloud已弃用。 Do not install this library or use it.不要安装或使用这个库。

Example code to get you started with Text to Speech:让您开始使用文本到语音的示例代码:

from google.cloud import texttospeech

# Instantiates a client
client = texttospeech.TextToSpeechClient()

# Set the text input to be synthesized
synthesis_input = texttospeech.types.SynthesisInput(text="Hello, World!")

# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")
voice = texttospeech.types.VoiceSelectionParams(
    language_code='en-US',
    ssml_gender=texttospeech.enums.SsmlVoiceGender.NEUTRAL)

# Select the type of audio file you want returned
audio_config = texttospeech.types.AudioConfig(
    audio_encoding=texttospeech.enums.AudioEncoding.MP3)

# Perform the text-to-speech request on the text input with the selected
# voice parameters and audio file type
response = client.synthesize_speech(synthesis_input, voice, audio_config)

# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
    # Write the response to the output file.
    out.write(response.audio_content)
    print('Audio content written to file "output.mp3"')

pip3 install google-cloud-bigquery pip3 安装 google-cloud-bigquery

this worked for me这对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自google.cloud导入firestore ModuleNotFoundError:没有名为'google'的模块 - from google.cloud import firestore ModuleNotFoundError: No module named 'google' 从google.cloud导入bigquery ModuleNotFoundError:没有名为“ google”的模块 - from google.cloud import bigquery ModuleNotFoundError: No module named 'google' ModuleNotFoundError:没有名为“google.cloud”的模块,即使我安装了它 - ModuleNotFoundError: No module named 'google.cloud' even though I installed it 来自google.cloud导入语言ModuleNotFoundError:没有名为“ google.cloud”的模块 - from google.cloud import language ModuleNotFoundError: No module named 'google.cloud' 没有名为 google.cloud 的模块 - No module named google.cloud from google.cloud import Speech_v1 ---- ModuleNotFoundError: No module named 'google' - from google.cloud import speech_v1 ---- ModuleNotFoundError: No module named 'google' 没有名为“google.cloud”的模块 Dockerfile python - No module named 'google.cloud' Dockerfile python 导入错误:ApacheBeam 上没有名为“google.cloud”的模块 - Import Error: No module named 'google.cloud' on ApacheBeam ModuleNotFoundError:没有名为“icalendar”的模块谷歌云 - ModuleNotFoundError: No module named 'icalendar' google Cloud 谷歌云计算上的“ModuleNotFoundError:没有名为‘pycocotools’的模块” - "ModuleNotFoundError: No module named 'pycocotools'" on google cloud compute
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM