技术知识分享

解决docker-compose启动时urllib3报错的问题

使用pip安装了docker-compose之后,启动时报了如下如下错误:

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in 
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 17, in 
    from . import errors
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/errors.py", line 11, in 
    from docker.errors import APIError
  File "/usr/local/lib/python2.7/dist-packages/docker/__init__.py", line 2, in 
    from .api import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/__init__.py", line 2, in 
    from .client import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 11, in 
    from .build import BuildApiMixin
  File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", line 9, in 
    from .. import utils
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/__init__.py", line 2, in 
    from .build import tar, exclude_paths
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/build.py", line 5, in 
    from .utils import create_archive
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", line 18, in 
    from .. import tls
  File "/usr/local/lib/python2.7/dist-packages/docker/tls.py", line 5, in 
    from .transport import SSLAdapter
  File "/usr/local/lib/python2.7/dist-packages/docker/transport/__init__.py", line 3, in 
    from .ssladapter import SSLAdapter
  File "/usr/local/lib/python2.7/dist-packages/docker/transport/ssladapter.py", line 22, in 
    urllib3.connection.match_hostname = match_hostname
AttributeError: 'module' object has no attribute 'connection'

在谷歌上查了一下,发现GitHub上有人报过类似issue,结果发现要升级urllib3的版本,还要需改一下path

pip install urllib3

and

export PYTHONPATH=/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages

另外,如果是系统初装,urllib3会报insecure的错误

apt-get install python-openssl

完美解决

发现了一个可以避免的办法,就是不使用ubuntu自带的pip安装

sudo easy_install pip
pip install docker-compose

本文原作者:Bruce(已经不幸被墙了就不放地址了)

未经允许不得转载:pc6a学习分享 » 解决docker-compose启动时urllib3报错的问题
vultr 云服务器VPS送50美金

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址