pip安装docker-compose的小坑

hello 大家好,最近小编在用docker-compose部署wordpress遇到了一个很无语的问题:

[root@200250229-registry ~]# pip install docker-compose
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: docker-compose in /usr/local/python3.10/lib/pyt0/site-packages (1.29.2)
Requirement already satisfied: PyYAML<6,>=3.10 in /usr/local/python3.10/lib/py10/site-packages (from docker-compose) (5.4.1)
Requirement already satisfied: python-dotenv<1,>=0.13.0 in /usr/local/python3./python3.10/site-packages (from docker-compose) (0.20.0)
Requirement already satisfied: websocket-client<1,>=0.32.0 in /usr/local/pytholib/python3.10/site-packages (from docker-compose) (0.59.0)
Requirement already satisfied: dockerpty<1,>=0.4.1 in /usr/local/python3.10/lion3.10/site-packages (from docker-compose) (0.4.1)
Requirement already satisfied: docker[ssh]>=5 in /usr/local/python3.10/lib/pyt0/site-packages (from docker-compose) (5.0.3)
Requirement already satisfied: distro<2,>=1.5.0 in /usr/local/python3.10/lib/p.10/site-packages (from docker-compose) (1.7.0)
Requirement already satisfied: texttable<2,>=0.9.0 in /usr/local/python3.10/lion3.10/site-packages (from docker-compose) (1.6.4)
Requirement already satisfied: docopt<1,>=0.6.1 in /usr/local/python3.10/lib/p.10/site-packages (from docker-compose) (0.6.2)
Requirement already satisfied: jsonschema<4,>=2.5.1 in /usr/local/python3.10/lhon3.10/site-packages (from docker-compose) (3.2.0)
Requirement already satisfied: requests<3,>=2.20.0 in /usr/local/python3.10/lion3.10/site-packages (from docker-compose) (2.27.1)
Requirement already satisfied: paramiko>=2.4.2 in /usr/local/python3.10/lib/py10/site-packages (from docker[ssh]>=5->docker-compose) (2.10.3)
Requirement already satisfied: six>=1.3.0 in /usr/local/python3.10/lib/python3te-packages (from dockerpty<1,>=0.4.1->docker-compose) (1.16.0)
Requirement already satisfied: setuptools in /usr/local/python3.10/lib/python3te-packages (from jsonschema<4,>=2.5.1->docker-compose) (58.1.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /usr/local/python3.10/libn3.10/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (0.18.1)
Requirement already satisfied: attrs>=17.4.0 in /usr/local/python3.10/lib/pyth/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (21.4.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/python3.10/libn3.10/site-packages (from requests<3,>=2.20.0->docker-compose) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/python3.10/lib/pythosite-packages (from requests<3,>=2.20.0->docker-compose) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/python3.10/thon3.10/site-packages (from requests<3,>=2.20.0->docker-compose) (1.26.9)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/python3b/python3.10/site-packages (from requests<3,>=2.20.0->docker-compose) (2.0.12)
Requirement already satisfied: bcrypt>=3.1.3 in /usr/local/python3.10/lib/pyth/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (3.2.0)
Requirement already satisfied: pynacl>=1.0.1 in /usr/local/python3.10/lib/pyth/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (1.5.0)
Requirement already satisfied: cryptography>=2.5 in /usr/local/python3.10/lib/3.10/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (36.
Requirement already satisfied: cffi>=1.1 in /usr/local/python3.10/lib/python3.e-packages (from bcrypt>=3.1.3->paramiko>=2.4.2->docker[ssh]>=5->docker-compos15.0)
Requirement already satisfied: pycparser in /usr/local/python3.10/lib/python3.e-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko>=2.4.2->docker[ssh]>=5->doompose) (2.21)
WARNING: Running pip as the 'root' user can result in broken permissions and cting behaviour with the system package manager. It is recommended to use a virnvironment instead: https://pip.pypa.io/warnings/venv
[root@200250229-registry ~]# docker-compose version
-bash: docker-compose: command not found
#小编我是真无语,明明已经安装成功,却提示命令找不到!

接下来我尝试用find命令去搜一下看看我到底有没有安装成功docker-compose

[root@200250229-registry ~]# find / -name "docker-compose*"
/usr/local/python3.10/bin/docker-compose

#在这里我们可以发现,docker-compose在这台机子已经被安装成功了

#接下来我们进入到/usr/local/python3.10/bin/docker-compose中并直接执行 version的命令

[root@200250229-registry ~]# /usr/local/python3.10/bin/docker-compose version
docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.10.4
OpenSSL version: OpenSSL 1.1.1n  15 Mar 2022

#我们可可以查看docker-compose的版本信息了。说明安装成功
#然而我们再次切换到~下,再次执行docker-compose verson依然没有用
[root@200250229-registry ~]# docker-compose version
-bash: docker-compose: command not found
#朋友们,接下来应该知道怎么解决了吧

看来是docker-compose没有加入到/usr/bin中,这个时候我们只需要建立一个软链接就完事!

[root@200250229-registry ~]# ln -s /usr/local/python3.10/bin/docker-compose /usr/bin/docker-compose 

#建立软链接就相当于在windows系统中给软件添加一个快捷方式

[root@200250229-registry ~]# docker-compose version
docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.10.4
OpenSSL version: OpenSSL 1.1.1n  15 Mar 2022
#看完之后,猛然发现,自己的linux掌握的还不够

ok,问题解决了?

总结:

当下次我们再遇到-bash: xxxxx: command not found的命令的时候有以下解决办法

  1. 检查自己有没有安装这个软件(可以使用find / -name "xxxx*")查看,没有东西就去安装
  2. 在/usr/bin下面查看是否有该命令。如果没有的话创建一个软连接:ln -s /usr/local/xxxxx/bin/docker-compose /usr/bin/xxx

你可能感兴趣的:(我的linux踩坑日记,linux)