docker-py: docker.from_env() causes TypeError: load_config() got an unexpected keyword argument 'config_dict'

After upgrading docker to Server Version: 17.12.0-ce and docker-py to 3.0.1

Getting error:

Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/usr/lib/python2.7/site-packages/docker/client.py”, line 81, in from_env **kwargs_from_env(**kwargs)) File “/usr/lib/python2.7/site-packages/docker/client.py”, line 38, in init self.api = APIClient(*args, **kwargs) File “/usr/lib/python2.7/site-packages/docker/api/client.py”, line 110, in init config_dict=self._general_configs TypeError: load_config() got an unexpected keyword argument ‘config_dict’

When using simple call

import docker
c = docker.from_env()

Is it a known bug? What version of docker-py is compatible with docker17.12.0-ce ?

Regards

P.S. downgrading to docker-py2.7 solves the issue

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I’m getting this issue too. Not sure exactly why it’s triggering, but I do notice there are two load_config functions:

/usr/local/lib/python2.7/dist-packages/docker/auth/auth.py:def load_config(config_path=None):
/usr/local/lib/python2.7/dist-packages/docker/auth.py:def load_config(config_path=None, config_dict=None):

Looking at the names of the files and directories I wonder if there is an importing order difference that causes it for some people to import the wrong module?

Also, this is the output of pip freeze:

docker==3.4.1
docker-compose==1.22.0
docker-py==1.10.6

Apparently docker is the replacement for docker-py, but does not conflict with it, so they simply install over each other. To fix this you have to uninstall both of them, then install just the right one. (And hope other pypi modules don’t pull the old module).

You probably have old artifacts messing up your imports. Remove all docker and docker-py packages (inside/outside virtualenv) then reinstall.

I am getting the same error in a pipenv virtualenv

$ docker --version          
Docker version 17.12.1-ce, build 7390fc6

under Python 3.6.4,

$ pipenv graph           
click==6.7
crayons==0.1.2
  - colorama [required: Any, installed: 0.3.9]
docker==3.1.2
  - docker-pycreds [required: >=0.2.2, installed: 0.2.2]
    - six [required: >=1.4.0, installed: 1.11.0]
  - requests [required: !=2.18.0,>=2.14.2, installed: 2.18.4]
    - certifi [required: >=2017.4.17, installed: 2018.1.18]
    - chardet [required: <3.1.0,>=3.0.2, installed: 3.0.4]
    - idna [required: >=2.5,<2.7, installed: 2.6]
    - urllib3 [required: >=1.21.1,<1.23, installed: 1.22]
  - six [required: >=1.4.0, installed: 1.11.0]
  - websocket-client [required: >=0.32.0, installed: 0.47.0]
    - six [required: Any, installed: 1.11.0]
GitPython==2.1.8
  - gitdb2 [required: >=2.0.0, installed: 2.0.3]
    - smmap2 [required: >=2.0.0, installed: 2.0.3]
giturlparse==0.9
halo==0.0.12
  - backports.shutil-get-terminal-size [required: ==1.0.0, installed: 1.0.0]
  - colorama [required: ==0.3.9, installed: 0.3.9]
  - cursor [required: ==1.2.0, installed: 1.2.0]
  - log-symbols [required: ==0.0.11, installed: 0.0.11]
    - colorama [required: ==0.3.9, installed: 0.3.9]
    - enum34 [required: ==1.1.6, installed: 1.1.6]
  - six [required: ==1.11.0, installed: 1.11.0]
  - spinners [required: ==0.0.19, installed: 0.0.19]
    - enum34 [required: ==1.1.6, installed: 1.1.6]
  - termcolor [required: ==1.1.0, installed: 1.1.0]
ipython==6.2.1
  - decorator [required: Any, installed: 4.2.1]
  - jedi [required: >=0.10, installed: 0.11.1]
    - parso [required: ==0.1.1, installed: 0.1.1]
  - pexpect [required: Any, installed: 4.4.0]
    - ptyprocess [required: >=0.5, installed: 0.5.2]
  - pickleshare [required: Any, installed: 0.7.4]
  - prompt-toolkit [required: <2.0.0,>=1.0.4, installed: 1.0.15]
    - six [required: >=1.9.0, installed: 1.11.0]
    - wcwidth [required: Any, installed: 0.1.7]
  - pygments [required: Any, installed: 2.2.0]
  - setuptools [required: >=18.5, installed: 39.0.1]
  - simplegeneric [required: >0.8, installed: 0.8.1]
  - traitlets [required: >=4.2, installed: 4.3.2]
    - decorator [required: Any, installed: 4.2.1]
    - ipython-genutils [required: Any, installed: 0.2.0]
    - six [required: Any, installed: 1.11.0]
numpy==1.14.2

Traceback

Traceback (most recent call last):
  File "dockapt.py", line 12, in <module>
    docker_client = docker.from_env()
  File "/home/dev/.local/share/virtualenvs/dockapt-LVPjMQXP/lib/python3.6/site-packages/docker/client.py", line 81, in from_env
    **kwargs_from_env(**kwargs))
  File "/home/dev/.local/share/virtualenvs/dockapt-LVPjMQXP/lib/python3.6/site-packages/docker/client.py", line 38, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/home/dev/.local/share/virtualenvs/dockapt-LVPjMQXP/lib/python3.6/site-packages/docker/api/client.py", line 110, in __init__
    config_dict=self._general_configs
TypeError: load_config() got an unexpected keyword argument 'config_dict'

Here are my Pipfile and Pipfile.lock

dockapt.zip

UPDATE:

Downgrading to docker==2.7.0 using pipenv install "docker<3" solves the issue

You can’t have docker and docker-py in the same environment, they’re incompatible.

i’m confused sorry, what should be installed then? just docker? docker-py docs offers to run:

pip install docker
import docker

what is docker-py, then?