Natural Language API on app engine

655 views
Skip to first unread message

Trung Huu Truong

unread,
Apr 16, 2018, 9:20:13 AM4/16/18
to Google Cloud Developers

I'm trying to use google natural language API on GAE but it fails to import the language module.
I've run pip install -t lib google-cloud-language. Anyone please helps to solve this?

  File "/base/data/home/apps/s~mcnamara-newslyzer/20180416t111430.409051101047882149/lib/google/cloud/language.py", line 17, in <module>
    from google.cloud.language_v1 import LanguageServiceClient
  File "/base/data/home/apps/s~mcnamara-newslyzer/20180416t111430.409051101047882149/lib/google/cloud/language_v1/__init__.py", line 17, in <module>
    from google.cloud.language_v1 import types
ImportError: cannot import name types

Kenworth (Google Cloud Platform)

unread,
Apr 16, 2018, 1:04:24 PM4/16/18
to google-c...@googlegroups.com
What was the environment you are running it to? Please provide reproducible steps, if any.

Trung Huu Truong

unread,
Apr 16, 2018, 11:25:57 PM4/16/18
to Google Cloud Developers
I'm using standard environment.
I created my project as following.
1. app.py using flask
2. pip install -t lib google-cloud google-cloud-language
3. in app.py: from google.cloud import language
vendor('lib') has been add to appengine config

there is also google-cloud/language package under python2.7 site-packages and I can test my api calls successfully using python.
dev_appserver tells different errors, it fails with no module language.
When deploy to app engine, I got types import error

Then the errors.

Kenworth (Google Cloud Platform)

unread,
Apr 17, 2018, 1:29:35 PM4/17/18
to Google Cloud Developers
Thank you for providing more information. You mentioned 'app.py', did you mean app.yaml or main.py? Usually you write the contents of your application on 'main.py' and you configure the settings on 'app.yaml'

To discount the possibility that it is a development environment issue, I recommend you go through our quick tutorial on GAE Standard with Flask or try to use this GitHub sample app. Let me know if you encounter any errors using the tutorial app.
Reply all
Reply to author
Forward
0 new messages