1

I've had a python app running in google app engine for over a year. I'm attempting to use the sentiment analysis.

from google.cloud import language

I get this error:

from google.cloud import language ImportError: cannot import name language.

It may be similar to this: from google.cloud import language ImportError: No module named cloud

It seems like something has changed in terms of the google modules. I also have these in my code:

from google.appengine.api import urlfetch
from google.appengine.api import taskqueue
from google.appengine.ext import ndb
from google.appengine.ext import deferred

Thanks,

I'm digging into this more. I think I have my installation messed up when I updated the google cloud sdk.

It looks like I have two locations for the google modules:

C:\Users\username\lib\google
C:\Python27\Lib\site-packages\google\cloud\language

Here's some more information about my configuration using gcloud info.

Python Location: [C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe]
Site Packages: [Disabled]

System PATH: [C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\bin\sdk;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files (x86)\Google\Chrome\Application;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Sennheiser\SoftphoneSDK\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Python27\;C:\Python27\Scripts;C:\Users\username\scoop\apps\python\current\scripts;C:\Users\username\AppData\Local\Programs\Python\Launcher\;C:\Users\username\scoop\shims;C:\Users\username\AppData\Local\Microsoft\WindowsApps;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin;]
Python PATH: [C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\..\lib\third_party;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python27.zip;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\DLLs;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\lib;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\lib\plat-win;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\lib\lib-tk;C:\Users\username\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython]
Cloud SDK on PATH: [True]
Paolo
  • 20,112
  • 21
  • 72
  • 113
RMO
  • 11
  • 1
  • 5
  • Did you vendor in the `google-cloud-language` in your app? https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27#installing_a_third-party_library – Dan Cornilescu Jul 22 '17 at 15:27
  • Thanks, Dan. I believe you're correct. I think I've messed up my install when I updated to the latest version of the cloud SDK. Frankly, I've never understood where the google packages needed to be installed--I always just took the defaults from the installer. – RMO Jul 22 '17 at 15:40
  • Read that doc section carefully - vendoring in is done *inside* your app code (and it's uploaded to GAE together with your app code) - GAE treats it like your app code. Not much to do with your local python instalation, which SDK version or where it is installed. – Dan Cornilescu Jul 22 '17 at 20:53
  • Dan, thanks for your help and you work correct. I needed to vendor it in. Ultimately I did this: pip install -t lib/ --upgrade google-api-python-client pip install -t lib/ --upgrade google-cloud – RMO Jul 22 '17 at 21:38

1 Answers1

0

Dan was correct. I needed to vendor in the google-cloud-language my app. I used the link that Dan posted: https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27#installing_a_third-party_library

Ultimately I did this from my project directory:

pip install -t lib/ --upgrade google-api-python-client
pip install -t lib/ --upgrade google-cloud
RMO
  • 11
  • 1
  • 5