ImportError cannot import 'langauge' from 'google.cloud' (unknown location)

724 Views Asked by At

I'm trying to incorporate google-cloud-language to use sentiment analysis. I followed the guide on the google documentation website, like so:

from google.cloud import language

When I run the script I receive the following error:

ImportError cannot import 'langauge' from 'google.cloud' (unknown location)

I try to run the script like so:

python3 scriptName.py

I've installed google-cloud-language like so:

pip3 install gooogle-cloud-language

pip install google-cloud-language

I've done that in a virtual environment and outside a virtual environment.

Nothing works. How do I properly set up my script to successfully import the NLP module from google cloud?

2

There are 2 best solutions below

1
On BEST ANSWER

Happy to see that you resolved your issue. However, I would like to point some things out:

  1. In the error that you posted in the description there is a typo. It looked for a module named langauge instead of language.

  2. pip3 install gooogle-cloud-language and python3 -m pip install google-cloud-language should be equivalent but that may not always be the case. For example when they are not in the same path. Check this answer for more details.

1
On

As I was writing this question and going through other similar questions on stackoverflow, I found another command to try and it seems to have worked.

python3 -m pip install google-cloud-language

I did this inside my virtualenv. It could also work outside of one, but because I got it working, I did not test the outside virtualenv case.