question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No module named docker

See original GitHub issue

I’ve installed docker-py using sudo pip install docker-py. Here are my details:

$ pip freeze | grep docker-py && python --version && docker version
docker-py==1.5.0
Python 2.7.6
Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 05:37:18 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 05:37:18 UTC 2015
 OS/Arch:      linux/amd64

When I go into python and try to import it, I get:

>>> from docker import Client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named docker

However, if instead I clone this repo and run the setup.py install, I can import docker. I guess there’s something different between the version in the PyPI and github?

Here’s the version information for the docker-py installation that works:

$ pip freeze | grep docker-py && python --version && docker version
docker-py==1.6.0-dev
Python 2.7.6
Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:43:42 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:43:42 UTC 2015
 OS/Arch:      linux/amd64

Here’s my python version information:

$ python --version
Python 2.7.6

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
TomasTomecekcommented, Nov 9, 2015

To me it looks like that you install docker-py for python 2 and you are trying to import it in python 3. Or your $PYTHONPATH is misconfigured.

EDIT: does any of these work?

$ python2 -c "import docker"
$ python3 -c "import docker"
2reactions
CatherineHcommented, Nov 11, 2015

I installed pip from the github repo (this is because I believe the debian package python-pip to be too out of date). Then used pip to install docker-py, i.e.:

git clone https://github.com/pypa/pip
cd pip
sudo python setup.py install
sudo pip install docker-py
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Fixed] ModuleNotFoundError: No module named 'docker'
How to Fix “ModuleNotFoundError: No module named 'docker'” in PyCharm · Open File > Settings > Project from the PyCharm menu. · Select...
Read more >
Failed to import docker or docker-py - No module named docker
The python3-docker module must be installed on the Target machine. I always tried to fix it on my local machine where the runbooks...
Read more >
Ansible No module named 'docker' error - Bobcares
What causes no module named 'docker' error? ... Let us see what causes this error. Ansible uses python to deploy changes in the...
Read more >
Fix ModuleNotFoundError (No Module Named docker) Python ...
In this tutorial I'll show you how to install and import docker package in your python program if you get ModuleNotFoundError no module...
Read more >
ModuleNotFoundError: No module named 'docker'
ModuleNotFoundError: No module named 'docker' ... How to remove the ModuleNotFoundError: No module named 'docker' error? ... Hi,. In your python environment you ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found