Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))
1.手动编译安装python3
2.通过pip3安装docker、docker-compose
安装docker-compose过程中有报错,升级一下pip3
python3 -m pip install --upgrade pip
[root@VM-99-6-centos awx-17.0.1]# pip3 install docker-compose
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting docker-compose
Using cached http://mirrors.tencentyun.com/pypi/packages/f3/3e/ca05e486d44e38eb495ca60b8ca526b192071717387346ed1031ecf78966/docker_compose-1.29.2-py2.py3-none-any.whl (114 kB)
Collecting dockerpty<1,>=0.4.1
Using cached http://mirrors.tencentyun.com/pypi/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz (13 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
解决办法: 升级setuptools python3 -m pip install --upgrade setuptools
[root@VM-99-6-centos awx-17.0.1]# python3 -m pip install --upgrade setuptools
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (58.1.0)
Collecting setuptools
Downloading http://mirrors.tencentyun.com/pypi/packages/fb/58/9efbfe68482dab9557c49d433a60fff9efd7ed8835f829eba8297c2c124a/setuptools-62.1.0-py3-none-any.whl (1.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 7.4 MB/s eta 0:00:00
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 58.1.0
Uninstalling setuptools-58.1.0:
Successfully uninstalled setuptools-58.1.0
Successfully installed setuptools-62.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@VM-99-6-centos awx-17.0.1]# pip3 install docker-compose
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting docker-compose
Using cached http://mirrors.tencentyun.com/pypi/packages/f3/3e/ca05e486d44e38eb495ca60b8ca526b192071717387346ed1031ecf78966/docker_compose-1.29.2-py2.py3-none-any.whl (114 kB)
Collecting distro<2,>=1.5.0
Downloading http://mirrors.tencentyun.com/pypi/packages/e1/54/d08d1ad53788515392bec14d2d6e8c410bffdc127780a9a4aa8e6854d502/distro-1.7.0-py3-none-any.whl (20 kB)
Collecting jsonschema<4,>=2.5.1
Using cached http://mirrors.tencentyun.com/pypi/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Collecting websocket-client<1,>=0.32.0
Downloading http://mirrors.tencentyun.com/pypi/packages/f7/0c/d52a2a63512a613817846d430d16a8fbe5ea56dd889e89c68facf6b91cb6/websocket_client-0.59.0-py2.py3-none-any.whl (67 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.2/67.2 KB 4.7 MB/s eta 0:00:00
Collecting docopt<1,>=0.6.1
Using cached http://mirrors.tencentyun.com/pypi/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz (25 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: docker[ssh]>=5 in /usr/local/lib/python3.9/site-packages (from docker-compose) (5.0.3)
Collecting python-dotenv<1,>=0.13.0
Downloading http://mirrors.tencentyun.com/pypi/packages/30/5f/2e5c564bd86349fe6b82ca840f46acf6f4bb76d79ba9057fce3d3e008864/python_dotenv-0.20.0-py3-none-any.whl (17 kB)
Requirement already satisfied: requests<3,>=2.20.0 in /usr/local/lib/python3.9/site-packages (from docker-compose) (2.27.1)
Collecting dockerpty<1,>=0.4.1
Using cached http://mirrors.tencentyun.com/pypi/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz (13 kB)
Preparing metadata (setup.py) ... done
Collecting PyYAML<6,>=3.10
Using cached http://mirrors.tencentyun.com/pypi/packages/3d/1f/2a3705efca3b47161ceaaf52970a9d4b81cc84600818686ecd75093a00a5/PyYAML-5.4.1-cp39-cp39-manylinux1_x86_64.whl (630 kB)
Collecting texttable<2,>=0.9.0
Downloading http://mirrors.tencentyun.com/pypi/packages/75/23/8170868d04b153b1b9ed1bb84348212bb4a08f31b292ef9d7f6ea648fd49/texttable-1.6.4-py2.py3-none-any.whl (10 kB)
Collecting paramiko>=2.4.2
Downloading http://mirrors.tencentyun.com/pypi/packages/be/6f/f0ec5f5fb00d270ebd80946be561795c67468473eb495222794cae285d40/paramiko-2.10.3-py2.py3-none-any.whl (211 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 211.9/211.9 KB 6.9 MB/s eta 0:00:00
Collecting six>=1.3.0
Downloading http://mirrors.tencentyun.com/pypi/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pyrsistent>=0.14.0
Downloading http://mirrors.tencentyun.com/pypi/packages/41/cb/733dc14ca2ca17768ea28254b95dbc98f398e46dbf4dba94d4fac491af6e/pyrsistent-0.18.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (115 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 115.6/115.6 KB 8.6 MB/s eta 0:00:00
Collecting attrs>=17.4.0
Downloading http://mirrors.tencentyun.com/pypi/packages/be/be/7abce643bfdf8ca01c48afa2ddf8308c2308b0c3b239a44e57d020afa0ef/attrs-21.4.0-py2.py3-none-any.whl (60 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.6/60.6 KB 6.5 MB/s eta 0:00:00
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (62.1.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (1.26.9)
Collecting cryptography>=2.5
Downloading http://mirrors.tencentyun.com/pypi/packages/80/fd/19a0f5273141a128926b3564e1ba1e9563a8e38ae9c334bc14bf2e79fc9a/cryptography-36.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 10.0 MB/s eta 0:00:00
Collecting pynacl>=1.0.1
Downloading http://mirrors.tencentyun.com/pypi/packages/66/28/ca86676b69bf9f90e710571b67450508484388bfce09acf8a46f0b8c785f/PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 9.4 MB/s eta 0:00:00
Collecting bcrypt>=3.1.3
Downloading http://mirrors.tencentyun.com/pypi/packages/c0/75/323f3e9e051726cef8a1d71d340a208ed5fe9dbdebc13b83428355c1382e/bcrypt-3.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.9/61.9 KB 4.9 MB/s eta 0:00:00
Collecting cffi>=1.1
Downloading http://mirrors.tencentyun.com/pypi/packages/e2/25/00fd291e0872d43dabe070e7b761ba37453a1a94bd6e28c31b73112d8f0c/cffi-1.15.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (444 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 444.3/444.3 KB 8.8 MB/s eta 0:00:00
Collecting pycparser
Downloading http://mirrors.tencentyun.com/pypi/packages/62/d5/5f610ebe421e85889f2e55e33b7f9a6795bd982198517d912eb1c76e1a53/pycparser-2.21-py2.py3-none-any.whl (118 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 KB 11.0 MB/s eta 0:00:00
Using legacy 'setup.py install' for dockerpty, since package 'wheel' is not installed.
Using legacy 'setup.py install' for docopt, since package 'wheel' is not installed.
Installing collected packages: texttable, docopt, six, PyYAML, python-dotenv, pyrsistent, pycparser, distro, attrs, websocket-client, jsonschema, dockerpty, cffi, pynacl, cryptography, bcrypt, paramiko, docker-compose
Running setup.py install for docopt ... done
Attempting uninstall: websocket-client
Found existing installation: websocket-client 1.3.2
Uninstalling websocket-client-1.3.2:
Successfully uninstalled websocket-client-1.3.2
Running setup.py install for dockerpty ... done
Successfully installed PyYAML-5.4.1 attrs-21.4.0 bcrypt-3.2.0 cffi-1.15.0 cryptography-36.0.2 distro-1.7.0 docker-compose-1.29.2 dockerpty-0.4.1 docopt-0.6.2 jsonschema-3.2.0 paramiko-2.10.3 pycparser-2.21 pynacl-1.5.0 pyrsistent-0.18.1 python-dotenv-0.20.0 six-1.16.0 texttable-1.6.4 websocket-client-0.59.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv