3

我無法導入google.cloud.speech導入錯誤:沒有名爲模塊google.cloud

from google.cloud import speech 

我一直在使用安裝了它:

pip install --upgrade google-cloud-speech -t dir-name 

這是給我下面的錯誤,而將其導入來自dir-name

ImportError: No module named google.cloud 

谷歌包與所有子包是存在那裏但沒有__init__ .py在每個子包中也是如此。

如何導入此包而不在包文件夾中添加__init__ .py?

PS:我也嘗試從__future__導入absolute_import,但它不工作。

+0

我也有同樣的錯誤 - 創建專用的虛擬環境幫助。 – Khozzy

回答

0

我用sudo python -m pip install google-cloud取而代之,它的工作。

0

試試這個:

$ git clone https://github.com/GoogleCloudPlatform/google-cloud-python 
$ cd google-cloud-python/speech 
$ python setup.py install 

Ref

1

根據需要,「Cloud Speech API客戶端庫」文檔page上的說明現在有效並且安裝成功。我使用:pip install --upgrade google-cloud-speech命令在Debian機器上安裝了Python庫。 這是一個alpha版本,功能可以隨時更改,在這種情況下效果更好。

相關問題