我在运行 Google Cloud Natural Language API 时遇到了很多麻烦。我正在尝试在 Google VM 上的 Linux 中运行 Python 程序。我也不确定如何运行错误的完整追溯。以下代码不起作用:
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types
.
在 Python 2 上出现错误:
Traceback (most recent call last):
File "natlangex.py", line 3, in <module>
from google.cloud.language import enums
ImportError: cannot import name enums
我尝试升级到 Python 3,当我运行 Python 3 时出现错误:我更新到 Python 3。令人困惑的一件事是,当我运行 Python 3 时,错误有点不同:
Traceback (most recent call last):
File "natlangex.py", line 2, in <module>
from google.cloud import language
ImportError: No module named 'google'
以下是我尝试过的其他事情:
- 我安装了 SDK。
- 我设置
export GOOGLE_APPLICATION_CREDENTIALS="apikey.json"
。 - 我试过了
!pip install google-cloud-language
- 我升级了点子
pip install --upgrade setuptools pip.
我很失落!先感谢您。