0

我在使用 Google Cloud NL Api 时收到此错误消息。

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-c22ac635f054> in <module>
      1 # Imports the Google Cloud client library
----> 2 from google.cloud import language
      3 from google.cloud.language import enums
      4 from google.cloud.language import types
      5 

ImportError: cannot import name 'language' from 'google.cloud' (unknown location)

我试图重新安装谷歌云语言。

该命令正在终端上运行(我得到了结果)

gcloud ml language analyze-entities --content="Michelangelo Caravaggio, Italian painter, is known for 'The Calling of Saint Matthew'."

我不认为我正在使用任何虚拟环境。

我想知道库是否安装在正确的位置,但我不知道如何确定?

4

1 回答 1

0

实际上它在这里说你应该在虚拟环境中安装这个库:

https://pypi.org/project/google-cloud-language/

(注意:去掉所有的<>,不需要“”)

pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-language

然后,如果您使用的是 Jupyter Notebook,您可以按照以下说明进行操作:

https://janakiev.com/blog/jupyter-virtual-envs/

最后,我从一个新的终端窗口重新启动了 Jupyter。从菜单中我选择了内核/更改内核/“您的环境名称”,它起作用了!

于 2020-07-11T16:03:59.630 回答