Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
w7089 opened this issue Feb 20, 2018 · 16 comments

Comments

@w7089
Copy link

w7089 commented Feb 20, 2018

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

@shin-
Copy link
Contributor

shin- commented Feb 20, 2018

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
Copy link

stephan227 commented Feb 23, 2018

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-
Copy link
Contributor

shin- commented Feb 25, 2018

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

@stephan227
Copy link

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

@scientifichackers
Copy link

scientifichackers commented Mar 20, 2018

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-
Copy link
Contributor

shin- commented Mar 20, 2018

Fixed in 3.1.3

#1968

@w7089
Copy link
Author

w7089 commented May 2, 2018

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-
Copy link
Contributor

shin- commented May 2, 2018

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

@hushenbeg
Copy link

@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
Copy link
Author

w7089 commented May 9, 2018

@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()

@shin-
Copy link
Contributor

shin- commented May 9, 2018

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

@w7089
Copy link
Author

w7089 commented May 9, 2018

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?

@geoffreywiseman
Copy link

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
Copy link

kleptog commented Jul 20, 2018

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
Copy link

pwaller commented Nov 14, 2018

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.

kushaldas added a commit to freedomofpress/securedrop that referenced this issue Feb 18, 2021
docker-py and docker both can not be installed on the same
virtualenv.

docker/docker-py#1916 (comment)
kushaldas added a commit to freedomofpress/securedrop that referenced this issue Feb 18, 2021
docker-py and docker both can not be installed on the same
virtualenv.

docker/docker-py#1916 (comment)
emkll pushed a commit to freedomofpress/securedrop that referenced this issue Feb 18, 2021
docker-py and docker both can not be installed on the same
virtualenv.

docker/docker-py#1916 (comment)
@imsheth
Copy link

imsheth commented Mar 26, 2021

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
Projects
None yet
Development

No branches or pull requests

8 participants