与Google App Engine一起使用时'from subprocess import _args_from_interpreter_flags'导入错误

时间:2019-06-14 00:45:33

标签: python-2.7 google-app-engine google-cloud-platform boto3

我已经检查了SO中的其他帖子,其中提到了同一问题here,但这并不是我的问题的答案。这是因为异常是由OP中在答案注释中报告的同名本地模块“子进程”引起的。

以下是我的问题的描述:

当我尝试在我的Google App Engine项目中使用boto3生成一个presigned_url的函数时,得到以下信息:

ERROR    2019-06-14 00:30:47,272 webapp2.py:1552] cannot import name _args_from_interpreter_flags
Traceback (most recent call last):
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/login/handlers.py", line 102, in dispatch
    webapp2.RequestHandler.dispatch(self)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/api.py", line 53, in wrapper
    return fn(self, *a, **k)
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/api.py", line 87, in _validate_csrf_token
    return fn(self, *a, **k)
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/fnapi/command.py", line 256, in post
    error, result = _run_cmd_fn(self, cmd_fn, ctx, payload)
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/fnapi/command.py", line 172, in _run_cmd_fn
    output = cmd_fn(ctx, payload)
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/upload_api.py", line 179, in generate_presigned_upload_url_cmd
    object_name, access_key, secret_key)
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/upload_api.py", line 45, in _generate_presigned_url
    aws_secret_access_key=secret_key)
  File "/Users/antkong/dev/my-project/appengine/app/lib/boto3/__init__.py", line 91, in client
    return _get_default_session().client(*args, **kwargs)
  File "/Users/antkong/dev/my-project/appengine/app/lib/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/Users/antkong/dev/my-project/appengine/app/lib/botocore/session.py", line 838, in create_client
    client_config=config, api_version=api_version)
  File "/Users/antkong/dev/my-project/appengine/app/lib/botocore/client.py", line 80, in create_client
    cls = self._create_client_class(service_name, service_model)
  File "/Users/antkong/dev/my-project/appengine/app/lib/botocore/client.py", line 110, in _create_client_class
    base_classes=bases)
  File "/Users/antkong/dev/my-project/appengine/app/lib/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/Users/antkong/dev/my-project/appengine/app/lib/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/Users/antkong/dev/my-project/appengine/app/lib/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/Users/antkong/dev/my-project/appengine/app/lib/boto3/utils.py", line 61, in _handler
    module = import_module(module)
  File "/Users/antkong/dev/my-project/appengine/app/lib/boto3/utils.py", line 52, in import_module
    __import__(name)
  File "/Users/antkong/dev/my-project/appengine/app/lib/boto3/s3/inject.py", line 15, in <module>
    from boto3.s3.transfer import create_transfer_manager
  File "/Users/antkong/dev/my-project/appengine/app/lib/boto3/s3/transfer.py", line 127, in <module>
    from s3transfer.exceptions import RetriesExceededError as \
  File "/Users/antkong/dev/my-project/appengine/app/lib/s3transfer/__init__.py", line 141, in <module>
    import s3transfer.compat
  File "/Users/antkong/dev/my-project/appengine/app/lib/s3transfer/compat.py", line 173, in <module>
    from multiprocessing.managers import BaseManager
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/__init__.py", line 65, in <module>
    from multiprocessing.util import SUBDEBUG, SUBWARNING
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/util.py", line 41, in <module>
    from subprocess import _args_from_interpreter_flags

但是,如果我在IDLE中本地尝试此操作,则不会有ImportError

$ python
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import _args_from_interpreter_flags
>>>

在其他地方,有人认为这可能是一个循环参考问题,并且可以通过抢先导入_args_from_interpreter_flags来解决。

但是,当我尝试使用它时,我的本地GAE服务器立即失败了:

INFO     2019-06-14 00:32:18,577 devappserver2.py:278] Skipping SDK update check.
INFO     2019-06-14 00:32:18,745 api_server.py:275] Starting API server at: http://localhost:49645
WARNING  2019-06-14 00:32:18,745 dispatcher.py:338] Your python27 micro version is below 2.7.12, our current production version.
INFO     2019-06-14 00:32:18,757 dispatcher.py:256] Starting module "app" running at: http://0.0.0.0:8080
INFO     2019-06-14 00:32:18,758 admin_server.py:150] Starting admin server at: http://0.0.0.0:8081
WARNING  2019-06-14 00:32:18,758 devappserver2.py:373] No default module found. Ignoring.
INFO     2019-06-14 00:32:20,974 instance.py:294] Instance PID: 43055
ERROR    2019-06-14 00:32:35,774 wsgi.py:263]
Traceback (most recent call last):
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/Users/antkong/dev/my-project/appengine/app/main.py", line 20, in <module>
    from my-project import (
  File "/Users/antkong/dev/my-project/appengine/app/src/my-project/upload_api.py", line 1, in <module>
    from subprocess import _args_from_interpreter_flags
ImportError: cannot import name _args_from_interpreter_flags

您能建议解决此问题的方法吗?

0 个答案:

没有答案