Google Cloud NL : ImportError

366 Views Asked by At

I am getting this error message with 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)

I tried to re-install google cloud language.

This command is working from the terminal (I get a result)

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

I don't think I'm using any virtual environment.

I'm wondering is the library is installed at the right location, but I don't know how to make sure?

1

There are 1 best solutions below

0
On

Actually it says here that you're supposed to install this library in a virtual environment:

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

(note: remove all the < >, and no "" needed)

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

Then if you're using Jupyter Notebook you can just follow these instructions:

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

At the end I restarted the Jupyter from a new terminal window. And from the menu I chose kernel / change kernel / "name of your environment" And it worked!