Skip to content

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

Closed
@w7089

Description

@w7089

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 "", line 1, in
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

Activity

shin-

shin- commented on Feb 20, 2018

@shin-
Contributor

That's quite odd - config_dict is a valid argument for load_config in 3.x, so there's no reason that error should happen.

Is it possible you have different versions of the package interfering with one another, maybe inside / outside a virtualenv?

stephan227

stephan227 commented on Feb 23, 2018

@stephan227

I am running into the same problem. I had to downgrade to docker-py2.7. Currently using docker Version 17.12.0-ce-mac49

I fixed it by removing python and python packages and re-installing python. Installing the legacy docker-py package appears to cause issues when installed along the latest docker package.

shin-

shin- commented on Feb 25, 2018

@shin-
Contributor

Is it possible you have different versions of the package interfering with one another, maybe inside / outside a virtualenv?

stephan227

stephan227 commented on Feb 26, 2018

@stephan227

Yes, different versions caused an issue on my machine. I had to remove python and re-install it.

ghost

ghost commented on Mar 20, 2018

@ghost

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

shin-

shin- commented on Mar 20, 2018

@shin-
Contributor

Fixed in 3.1.3

#1968

w7089

w7089 commented on May 2, 2018

@w7089
Author

Have the same issue still with docker 3.3.0

Traceback (most recent call last):
File "/net/netstore2/vol/paas_clusters_vol/cluster336/PAAS/paas-config/1.1.290/ServicePostDeploy/mariadb", line 77, in
docker_client = docker.from_env()
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'

shin-

shin- commented on May 2, 2018

@shin-
Contributor

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

hushenbeg

hushenbeg commented on May 3, 2018

@hushenbeg

@shin- i am using python 3.6 version and trying to import the docker
and i got the

TypeError: load_config() got an unexpected keyword argument 'config_dict'

please tell me whats happing exactly inside the code

w7089

w7089 commented on May 9, 2018

@w7089
Author

@shin- removed docker and docker-py packages, reinstalled docker and docker-py packages and getting the error still:

docker_client = docker.from_env()

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'

python version is

Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2

On other system, your suggestion helped:

Python 2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import docker
c = docker.from_env()

3 remaining items

geoffreywiseman

geoffreywiseman commented on Jun 20, 2018

@geoffreywiseman

I'm getting the sense that if I'm trying to use the docker module with Python2, I need to install "docker<3", but that's not covered by the module documentation anywhere that I can see? The README suggests to just install 'docker', and the pypi docs suggest 'docker' is compatible with Python2, but if I do that, I end up at this error.

kleptog

kleptog commented on Jul 20, 2018

@kleptog

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).

pwaller

pwaller commented on Nov 14, 2018

@pwaller

Apparently docker is the replacement for docker-py, but does not conflict with it, so they simply install over each other.

I hit this running docker-compose after an upgrade of docker-compose, and filed docker/compose#6339 there. Seems worth preventing that failure mode.

added a commit that references this issue on Feb 18, 2021
imsheth

imsheth commented on Mar 26, 2021

@imsheth

Issue with airflow 2.1.0 was that it had some compatibility issues with python 3.8 even though Airflow suggests that it works fine with python 3.8, I switched to fresh python 3.6 installation and everything worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @geoffreywiseman@pwaller@kleptog@shin-@imsheth

        Issue actions

          docker.from_env() causes TypeError: load_config() got an unexpected keyword argument 'config_dict' · Issue #1916 · docker/docker-py