Я уже проверил другой пост в SO , в котором упоминалась та же проблема здесь , но это не ответ на мою проблему.Это связано с тем, что исключение было вызвано локальным модулем с таким же именем «подпроцесс», о чем сообщает 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
Можете ли вы предложить способ решения проблемы?