Compose: an older version of the 'docker-py' package is polluting the namespace

Created on 3 Mar 2017  ยท  21Comments  ยท  Source: docker/compose

I just upgraded Docker For Mac to 17.03.0-ce-mac1

$ โฎ€docker-compose up -d
ERROR: Dependency conflict: an older version of the 'docker-py' package is polluting the namespace. Run the following command to remedy the issue:
pip uninstall docker docker-py; pip install docker
$ โฎ€pip uninstall docker docker-py; pip install docker
Cannot uninstall requirement docker, not installed
Collecting docker
  Downloading docker-2.1.0-py2.py3-none-any.whl (105kB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 112kB 3.6MB/s
Requirement already satisfied: six>=1.4.0 in ./VENV/lib/python2.7/site-packages (from docker)
Collecting backports.ssl-match-hostname>=3.5; python_version < "3.5" (from docker)
  Downloading backports.ssl_match_hostname-3.5.0.1.tar.gz
Requirement already satisfied: ipaddress>=1.0.16; python_version < "3.3" in ./VENV/lib/python2.7/site-packages (from docker)
Collecting websocket-client>=0.32.0 (from docker)
  Downloading websocket_client-0.40.0.tar.gz (196kB)
    100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 204kB 3.6MB/s
Collecting docker-pycreds>=0.2.1 (from docker)
  Downloading docker_pycreds-0.2.1-py2.py3-none-any.whl
Requirement already satisfied: requests!=2.11.0,!=2.12.2,>=2.5.2 in ./VENV/lib/python2.7/site-packages (from docker)
Building wheels for collected packages: backports.ssl-match-hostname, websocket-client
  Running setup.py bdist_wheel for backports.ssl-match-hostname ... done
  Stored in directory: /Users/anentropic/Library/Caches/pip/wheels/5d/72/36/b2a31507b613967b728edc33378a5ff2ada0f62855b93c5ae1
  Running setup.py bdist_wheel for websocket-client ... done
  Stored in directory: /Users/anentropic/Library/Caches/pip/wheels/d1/5e/dd/93da015a0ecc8375278b05ad7f0452eff574a044bcea2a95d2
Successfully built backports.ssl-match-hostname websocket-client
Installing collected packages: backports.ssl-match-hostname, websocket-client, docker-pycreds, docker
  Found existing installation: websocket-client 0.11.0
    Uninstalling websocket-client-0.11.0:
      Successfully uninstalled websocket-client-0.11.0
Successfully installed backports.ssl-match-hostname-3.5.0.1 docker-2.1.0 docker-pycreds-0.2.1 websocket-client-0.40.0
$ โฎ€docker-compose up -d
ERROR: Dependency conflict: an older version of the 'docker-py' package is polluting the namespace. Run the following command to remedy the issue:
pip uninstall docker docker-py; pip install docker
arecli kinenhancement

Most helpful comment

well, it's simply that docker package was not installed, so pip doesn't get around to uninstalling docker-py i.e. this https://github.com/pypa/pip/issues/3016

doing an individual pip uninstall docker-py fixed it for me

All 21 comments

well, it's simply that docker package was not installed, so pip doesn't get around to uninstalling docker-py i.e. this https://github.com/pypa/pip/issues/3016

doing an individual pip uninstall docker-py fixed it for me

I guess we should rewrite the command advice to take that possibility into account. Thanks for the report.

FWIW I got exactly the same issue - for me the difficulty in solving it was multiple versions of pip on my system - I had to type pip + [TAB] in bash to see the options and then try each to find the right one.

Just posting here in case someone else has the same issue and can learn from my fix, it took me about three days to work it out!

You can remove python.
image
And try docker-compose
image
This conflict because of you install docker-compose(1.5.2) by apt-get and you install docker-compose by phyton pip and uninstall docker-compose.Different versions of the messy operation caused.
You can remove python.And isntall docker-compose.
https://docs.docker.com/compose/install/

if you remove it you will get issue with awsebcli
Traceback (most recent call last):
File "/usr/local/bin/eb", line 6, in
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3036, in
@_call_aside
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in _call_aside
f(args, *kwargs)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3049, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 654, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 968, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 854, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'docker-py<=1.7.2,>=1.1.0' distribution was not found and is required by awsebcli
Checking if environment exist
Traceback (most recent call last):

is there any way to make it work together ?

docker, cocker-compose and awsebcli ?

@mirakl577 Use virtualenv to isolate awsebcli and docker-compose in separate environments.

I am having the same problem with awsebcli and docker complaining about docker-py. i've been switching back and forth trying to solve the issue. @shin- going to give the virtualenv a shot thanks.

Yes today morning I was thinking exactly about virtual env, thanks!

@mirakl577 and @shin- the virtualenv worked great for me. i uninstalled awsebcli, created a new env, installed it in there, and now Docker is happy and i can run my eb deploys again.

for anyone else having this issue, here is the AWS docs on how to set this up.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-virtualenv.html

@anentropic, I just ran into this issue after updating to the latest stable for mac. The installer asked for my credentials which I thought was a bit strange for an update considering the application and dependencies are mostly in my home directory or /usr/local/. When running any docker-compose command I would get the following error:

โ‡’  docker-compose build
ERROR: Dependency conflict: an older version of the 'docker-py' package is polluting the namespace. Run the following command to remedy the issue:
pip uninstall docker docker-py; pip install docker

However, I was unable to pip uninstall because of permissions issues. After looking at the permissions in /usr/local/lib/python2.7/site-packages I found that the docker and docker_py-1.10.6.dist-info directories were owned by root rather than my local user. Changing permissions to my user allowed me to pip uninstall docker docker-py and then subsequently run pip install docker which has resolved the issue for me.

This is not the first time updating docker for mac has screwed something up. It seems to semi-regularly delete my list of insecure registries and reset my VM settings (this time, it did both).

Updating to this version caused the issues:

Version 17.03.0-ce-mac2 (15654)
Channel: stable
1d7d97bbbd

We'd suggest something along the lines of:

$ pip uninstall docker
...
$ pip uninstall docker-py
...
$ pip install docker

(Note: You may need sudo if your Python package directory is not owned by your local user)

@nathanleclaire I was unable to run these commands as you suggested because the docker for Mac installer had mismatched the permissions. While my python package directory is owned by my local user, root was the owner of the docker and docker-py directories. Sudo was not an option as the directory was owned by my user, not root.

@jshapiro26 Yikes, sorry about that, @justincormack and crew this seems something that should be sorted out in the Docker for Mac installers...

I hit this issue on debian after upgrade from Jessie to Stretch. apt-get remove python-docker did the trick for me.

@jshapiro26 your approach to this issue worked for me on a ubuntu machine

Cc @jeanlaurent

On 20 Mar 2017 03:07, "mawunyega" notifications@github.com wrote:

@jshapiro26 https://github.com/jshapiro26 your approach to this issue
worked for me on a ubuntu machine

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker/compose/issues/4569#issuecomment-287671082,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAdcPMV8D-3ECSYSxShrnfl34L2cC4B1ks5rne2KgaJpZM4MSNuN
.

Hm, my entire Docker for Mac seems broken due to this issue as well (after messing with the pip packages)

screen shot 2017-03-20 at 12 17 36 pm

I use docker-py for glances, and since I upgraded from v1.10.0 (build 4bd6f1a) to v1.12.0 (build b31ff33) using:

curl -L "https://github.com/docker/compose/releases/download/1.12.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

I get the following when running any docker-compose command:

WARNING: Dependency conflict: an older version of the 'docker-py' package may be polluting the namespace. If you're experiencing crashes, run the following command to remedy the issue:
pip uninstall docker-py; pip uninstall docker; pip install docker

I don't have docker Python package since Docker was installed via apt-get on the https://apt.dockerproject.org/repo Ubuntu repository.

Tried to upgrade docker-py with pip install --upgrade docker-py: same issue.
Also tried upgrading Compose to v1.13.0-rc1, build 38af513: still the same issue.

@C-Duv In your case, that warning is safe to ignore.

EDIT: Reminder to check your darn project makefiles for every single instance of an instruction file for PIP that includes ANY of the Docker-compose (or ANY Docker) installations, because they WILL have STALE/ANCIENT versions embedded. I agree with the OP this certainly "pollutes" the environment, and in my case, trumped the system docker with very old versions giving very hard to troubleshoot results.

Just wanted to post my solution.

sudo apt autoremove

I guess even though I ran sudo apt remove docker-compose, there were still conflicting python packages installed via apt.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dimsav picture dimsav  ยท  3Comments

29e7e280-0d1c-4bba-98fe-f7cd3ca7500a picture 29e7e280-0d1c-4bba-98fe-f7cd3ca7500a  ยท  3Comments

bitver picture bitver  ยท  3Comments

foxx picture foxx  ยท  3Comments

Hendrik-H picture Hendrik-H  ยท  3Comments