GeezerVison is showing github.com — Fail to import ServiceAccountCredentials within GAE endpoint tool · Issue #1705 · googleapis/google-cloud-python
Fail to import ServiceAccountCredentials within GAE endpoint tool #1705Labels authtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionI am generating some GAE endpoints library. When running endpoints tool(endpointscfg.py get_client_lib ... ), gcloud import fails.
Third party libraries are bundled with GAE project, and oauth2client-2.0.1 is actually exists in library directory.
Affecting versions: 0.10 and above
Traceback (most recent call last):
File "/usr/local/bin/endpointscfg.py", line 133, in <module>
run_file(__file__, globals())
File "/usr/local/bin/endpointscfg.py", line 129, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
main(sys.argv)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
args.callback(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 426, in _GetClientLibCallback
hostname=args.hostname, application_path=args.application)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 388, in _GetClientLib
application_path=application_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 187, in GenApiConfig
module = __import__(module_name, fromlist=base_service_class_name)
File "/Users/kang/jackend/main.py", line 10, in <module>
from auth.services import JackEndAuthAPI
File "/Users/kang/jackend/auth/services.py", line 12, in <module>
from . import (
File "/Users/kang/jackend/auth/storage.py", line 9, in <module>
from ext import cloudstorage as storage
File "/Users/kang/jackend/ext/cloudstorage.py", line 9, in <module>
from gcloud import (
File "/Users/kang/jackend/lib/gcloud/storage/__init__.py", line 45, in <module>
from gcloud.storage.client import Client
File "/Users/kang/jackend/lib/gcloud/storage/client.py", line 19, in <module>
from gcloud.client import JSONClient
File "/Users/kang/jackend/lib/gcloud/client.py", line 17, in <module>
from oauth2client.service_account import ServiceAccountCredentials
ImportError: cannot import name ServiceAccountCredentials
Activityghost changed the title [-]Fails to import ServiceAccountCredentials in GAE endpoint tool[/-] [+]Fail to import ServiceAccountCredentials in GAE endpoint tool[/+] on Apr 8, 2016 ghost changed the title [-]Fail to import ServiceAccountCredentials in GAE endpoint tool[/-] [+]Fail to import ServiceAccountCredentials within GAE endpoint tool[/+] on Apr 8, 2016 jgeewax commented on Apr 8, 2016 Reacted by anasos and Alex added type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. on Apr 8, 2016jgeewax commented on Apr 8, 2016 OK -- if you have oauthclient 2.0.1 in your directory, then all you'd need to do is put it first in the PYTHONPATH environment variable and then it'll use that one. jgeewax commented on Apr 8, 2016 I actually don't know for sure, but all you need is to make sure the oauth2client that you have (which is the right version) is the one used by your code... I'd assume you'd need to vendor.add('path/to/oauth2client') dhermes commented on Apr 8, 2016 theacodes commented on Apr 8, 2016 The problem is that endpointscfg.py doesn't load appengine_config.py. I'm actually the one who reported this issue.
A workaround is to just import appengine_config yourself as soon as possible in your code. dhermes commented on Apr 8, 2016 @cyluss LMK if this doesn't work for you and we can re-open and discuss. theacodes commented on Apr 11, 2016 Can you print sys.path after importing appengine_config and oauth2client.__version__? theacodes commented on Apr 13, 2016 @cyluss sorry for the delay, can you tell me what oauth2client.__version__ and oauth2client.__file__ is after import appengine_config? theacodes commented on Apr 13, 2016 Can you try doing this nonsense in appengine_config.py after the vendor call?
import sys
if 'oauth2client' in sys.modules:
del sys.modules['oauth2client']theacodes commented on Apr 14, 2016 Great.
The long and short is that app engine is barrels of fun when it comes to user-provided newer versions of bundled libraries. Reacted by Alex Reacted by Mike Lambert Reacted by Mike Lambert
MetadataMetadataauthtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|