我无法导入google.cloud.speech
from google.cloud import speech
Run Code Online (Sandbox Code Playgroud)
我用它安装了它:
pip install --upgrade google-cloud-speech -t dir-name
Run Code Online (Sandbox Code Playgroud)
从dir-name导入时,它给出了以下错误
ImportError: No module named google.cloud
Run Code Online (Sandbox Code Playgroud)
包含所有子包的google包在那里,但在每个子包中也没有__init__ .py.
如何在不在包文件夹中添加__init__ .py的情况下导入此包?
PS:我也尝试过__future__ import absolute_import,但它无法正常工作.
python-import python-2.7 google-speech-api google-cloud-speech
我尝试按照我在此处找到的google教程运行下面的代码:https://cloud.google.com/docs/authentication/production
def implicit():
from google.cloud import storage
# If you don't specify credentials when constructing the client, the
# client library will look for credentials in the environment.
project = 'my_project_name'
storage_client = storage.Client(project=project)
# Make an authenticated API request
buckets = list(storage_client.list_buckets())
print(buckets)
implicit()
Run Code Online (Sandbox Code Playgroud)
但它一直给我以下错误:
Traceback (most recent call last):
File "[PATH]/scratch_5.py", line 13, in <module>
implicit()
File "[PATH]/scratch_5.py", line 2, in implicit
from google.cloud import storage
ImportError: cannot import name storage
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?