Docker-py: AttributeError: 'module' object has no attribute 'DockerClient'

Created on 30 Apr 2018  路  5Comments  路  Source: docker/docker-py

Followed example on https://docker-py.readthedocs.io/en/stable/client.html:

>>> import docker
>>> client = docker.DockerClient(base_url='unix://var/run/docker.sock')

Received the following error:

AttributeError: 'module' object has no attribute 'DockerClient'

Additional info:

# pip list | grep docker
docker-py                        1.10.6

# python -V
Python 2.7.5

Most helpful comment

You're using the wrong package. Uninstall docker-py and install docker instead.

All 5 comments

It looks like the documentation is out-of-date. The class is docker.Client, not docker.DockerClient:

cat /usr/lib/python2.7/site-packages/docker/client.py | grep class
class Client(

You're using the wrong package. Uninstall docker-py and install docker instead.

@shin- , I am using Python 2. The docker library erred with ImportError: No module named docker. Similar to the issue https://github.com/docker/docker-py/issues/844

You probably have some path conflicts.
Make sure to remove all copies of docker-py with pip uninstall (inside/outside virtualenvs, etc.) first, then uninstall and reinstall the docker package.

You probably have some path conflicts.

@shin- , I had to manually delete /usr/lib/python2.7/site-packages/docker and install again.

Was this page helpful?
0 / 5 - 0 ratings