ImportError: No module named urllib.parse
安裝docker編排工具compose時:
系統環境:centos7 ,python是自帶的2.7
[root@linux-node01 ~]# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@linux-node01 ~]# rpm -ivh epel-release-latest-7.noarch.rpm
[root@linux-node01 ~]# yum list python*-pip*
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
可安裝的軟件包
python-django-pipeline.noarch 1.3.24-1.el7 epel
python2-pip.noarch 8.1.2-5.el7 epel
python34-pip.noarch 8.1.2-5.el7 epel
[root@linux-node01 ~]# yum install python2-pip.noarch -y
[root@linux-node01 ~]# pip install --upgrade pip
[root@linux-node01 ~]# pip install docker-compose
........
Collecting dockerpty<0.5,>=0.4.1 (from docker-compose)
Downloading dockerpty-0.4.1.tar.gz
Collecting requests!=2.11.0,<2.12,>=2.6.1 (from docker-compose)
Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
100% |████████████████████████████████| 522kB 272kB/s
Collecting docopt<0.7,>=0.6.1 (from docker-compose)
Downloading docopt-0.6.2.tar.gz
Collecting docker-pycreds>=0.2.1 (from docker<3.0,>=2.5.1->docker-compose)
Downloading docker_pycreds-0.2.1-py2.py3-none-any.whl
Collecting functools32; python_version == "2.7" (from jsonschema<3,>=2.5.1->docker-compose)
Downloading functools32-3.2.3-2.zip
Installing collected packages: texttable, backports.ssl-match-hostname, websocket-client, ipaddress, docker-pycreds, requests, docker, functools32, jsonschema, cached-property, enum34, PyYAML, dockerpty, docopt, docker-compose
Running setup.py install for texttable ... done
Found existing installation: backports.ssl-match-hostname 3.4.0.2
Uninstalling backports.ssl-match-hostname-3.4.0.2:
Successfully uninstalled backports.ssl-match-hostname-3.4.0.2
Running setup.py install for backports.ssl-match-hostname ... done
Running setup.py install for functools32 ... done
Running setup.py install for PyYAML ... done
Running setup.py install for dockerpty ... done
Running setup.py install for docopt ... done
Successfully installed PyYAML-3.12 backports.ssl-match-hostname-3.5.0.1 cached-property-1.3.1 docker-2.5.1 docker-compose-1.16.1 docker-pycreds-0.2.1 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.6 functools32-3.2.3.post2 ipaddress-1.0.18 jsonschema-2.6.0 requests-2.11.1 texttable-0.9.1 websocket-client-0.44.0
[root@linux-node01 ~]# docker-compose -v
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 7, in <module>
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 17, in <module>
from . import errors
File "/usr/lib/python2.7/site-packages/compose/cli/errors.py", line 11, in <module>
from docker.errors import APIError
File "/usr/lib/python2.7/site-packages/docker/__init__.py", line 2, in <module>
from .api import APIClient
File "/usr/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in <module>
from .client import APIClient
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 9, in <module>
import websocket
File "/usr/lib/python2.7/site-packages/websocket/__init__.py", line 23, in <module>
from ._app import WebSocketApp
File "/usr/lib/python2.7/site-packages/websocket/_app.py", line 35, in <module>
from ._core import WebSocket, getdefaulttimeout
File "/usr/lib/python2.7/site-packages/websocket/_core.py", line 33, in <module>
from ._handshake import *
File "/usr/lib/python2.7/site-packages/websocket/_handshake.py", line 30, in <module>
from ._http import *
File "/usr/lib/python2.7/site-packages/websocket/_http.py", line 33, in <module>
from ._url import *
File "/usr/lib/python2.7/site-packages/websocket/_url.py", line 27, in <module>
from six.moves.urllib.parse import urlparse
ImportError: No module named urllib.parse
##報錯
解決方法:
pip install docker_pycreds
[root@linux-node01 ~]# docker-compose -v
docker-compose version 1.16.1, build 6d1ac219
ImportError: No module named urllib.parse