Moto: ModuleNotFoundError: No module named 'docker.errors'

Created on 8 Sep 2020  路  9Comments  路  Source: spulec/moto

With the latest version, I'm seeing this error in my tests this morning:

.tox/py37/lib/python3.7/site-packages/boto3/resources/factory.py:520: in do_action
--
410 | response = action(self, *args, **kwargs)
411 | .tox/py37/lib/python3.7/site-packages/boto3/resources/action.py:83: in __call__
412 | response = getattr(parent.meta.client, operation_name)(*args, **params)
413 | .tox/py37/lib/python3.7/site-packages/botocore/client.py:337: in _api_call
414 | return self._make_api_call(operation_name, kwargs)
415 | .tox/py37/lib/python3.7/site-packages/botocore/client.py:643: in _make_api_call
416 | operation_model, request_dict, request_context)
417 | .tox/py37/lib/python3.7/site-packages/botocore/client.py:662: in _make_request
418 | return self._endpoint.make_request(operation_model, request_dict)
419 | .tox/py37/lib/python3.7/site-packages/botocore/endpoint.py:102: in make_request
420 | return self._send_request(request_dict, operation_model)
421 | .tox/py37/lib/python3.7/site-packages/botocore/endpoint.py:137: in _send_request
422 | success_response, exception):
423 | .tox/py37/lib/python3.7/site-packages/botocore/endpoint.py:256: in _needs_retry
424 | caught_exception=caught_exception, request_dict=request_dict)
425 | .tox/py37/lib/python3.7/site-packages/botocore/hooks.py:356: in emit
426 | return self._emitter.emit(aliased_event_name, **kwargs)
427 | .tox/py37/lib/python3.7/site-packages/botocore/hooks.py:228: in emit
428 | return self._emit(event_name, kwargs)
429 | .tox/py37/lib/python3.7/site-packages/botocore/hooks.py:211: in _emit
430 | response = handler(**kwargs)
431 | .tox/py37/lib/python3.7/site-packages/botocore/retryhandler.py:183: in __call__
432 | if self._checker(attempts, response, caught_exception):
433 | .tox/py37/lib/python3.7/site-packages/botocore/retryhandler.py:251: in __call__
434 | caught_exception)
435 | .tox/py37/lib/python3.7/site-packages/botocore/retryhandler.py:269: in _should_retry
436 | return self._checker(attempt_number, response, caught_exception)
437 | .tox/py37/lib/python3.7/site-packages/botocore/retryhandler.py:317: in __call__
438 | caught_exception)
439 | .tox/py37/lib/python3.7/site-packages/botocore/retryhandler.py:223: in __call__
440 | attempt_number, caught_exception)
441 | .tox/py37/lib/python3.7/site-packages/botocore/retryhandler.py:359: in _check_caught_exception
442 | raise caught_exception
443 | .tox/py37/lib/python3.7/site-packages/botocore/endpoint.py:197: in _do_get_response
444 | responses = self._event_emitter.emit(event_name, request=request)
445 | .tox/py37/lib/python3.7/site-packages/botocore/hooks.py:356: in emit
446 | return self._emitter.emit(aliased_event_name, **kwargs)
447 | .tox/py37/lib/python3.7/site-packages/botocore/hooks.py:228: in emit
448 | return self._emit(event_name, kwargs)
449 | .tox/py37/lib/python3.7/site-packages/botocore/hooks.py:211: in _emit
450 | response = handler(**kwargs)
451 | .tox/py37/lib/python3.7/site-packages/moto/core/models.py:323: in __call__
452 | request, request.url, request.headers
453 | .tox/py37/lib/python3.7/site-packages/moto/core/responses.py:202: in dispatch
454 | return cls()._dispatch(*args, **kwargs)
455 | .tox/py37/lib/python3.7/site-packages/moto/core/responses.py:312: in _dispatch
456 | return self.call_action()
457 | .tox/py37/lib/python3.7/site-packages/moto/core/utils.py:245: in _wrapper
458 | response = f(*args, **kwargs)
459 | .tox/py37/lib/python3.7/site-packages/moto/core/utils.py:277: in _wrapper
460 | response = f(*args, **kwargs)
461 | .tox/py37/lib/python3.7/site-packages/moto/sqs/responses.py:71: in call_action
462 | status_code, headers, body = super(SQSResponse, self).call_action()
463 | .tox/py37/lib/python3.7/site-packages/moto/core/responses.py:397: in call_action
464 | response = method()
465 | .tox/py37/lib/python3.7/site-packages/moto/sqs/responses.py:243: in send_message
466 | group_id=message_group_id,
467 | .tox/py37/lib/python3.7/site-packages/moto/sqs/models.py:670: in send_message
468 | queue.add_message(message)
469 | .tox/py37/lib/python3.7/site-packages/moto/sqs/models.py:466: in add_message
470 | from moto.awslambda import lambda_backends
471 | .tox/py37/lib/python3.7/site-packages/moto/awslambda/__init__.py:2: in <module>
472 | from .models import lambda_backends
473 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
474 | 聽
475 | from __future__ import unicode_literals
476 | 聽
477 | import base64
478 | import time
479 | from collections import defaultdict
480 | import copy
481 | import datetime
482 | from gzip import GzipFile
483 | 聽
484 | import docker
485 | >   import docker.errors
486 | E   ModuleNotFoundError: No module named 'docker.errors'
487 | 聽
488 | .tox/py37/lib/python3.7/site-packages/moto/awslambda/models.py:11: ModuleNotFoundError

Seems that if I add docker to my own requirements.txt it fixes the problem. Not sure if this dependency was missed somehow or if pip is not picking it up for other reasons.

Most helpful comment

This was unintentional. Apologies.

Things should be back to before with the newly released 1.3.16.

All 9 comments

specifying moto[all] did not work

Also please update the documentation BEFORE pushing out a breaking patch release (which I feel was a poor choice of versioning) to PyPI. Thank you.

Seeing test failures due to this here as well.

Getting a similar error using sns - it looks like sns and sqs import the awslambda backend, so need the awslambda extras (docker). There should be extras defined for all services that include all of their transitive dependencies too (or no dependencies, which would make it easier for users to just add all of the services as "extras" even if they don't pull in any extra dependencies - and leave room for forward compatibility if they require some dependencies in the future). Or the sns and sqs mocks should gracefully handle an import error for the awslambda backend if it isn't actually used. Or both.

Using moto[all] or moto[awslambda] should fix the dependency for you, though. Using moto[awslambda] resolved the error in my case.

Again, I did try the moto[all] but didn't seem to work for me and had to add the docker package myself (this could have been a pip cache issue, IDK). Since I'm not explicitly using aws lamba, would have never known to include that package and a larger question then become how much of the moto[all] version is missing since it's obviously NOT really including all the dependencies. Before today, I've been using just moto (as is _still_ stated in the documentation) which has been fine forever, but with this latest change sadly breaks that without any warning.

Also having this issue with mocking dynamodb, resolved by freezing to version 1.3.14 suggesting that this update broke my tests and caused the following error.

botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the CreateTable operation: The security token included in the request is invalid.

This was unintentional. Apologies.

Things should be back to before with the newly released 1.3.16.

This still broken? Hitting it on moto==1.3.16.dev184

@chris-erickson Try using pip install moto[all]==1.3.16.dev184 - that does install docker for me

Was this page helpful?
0 / 5 - 0 ratings