【疑难杂症】【已解决】importlib.metadata.PackageNotFoundError: No package metadata was found for docker-compose
解决 Kali 2023 中使用 docker-compose 出现【ModuleNotFoundError: No module named 'compose.cli'; 'compose' is not a package】等报错的方法
·
前言
博主计算机小白,最近正在摸鱼学习web安全
年中安装了kali2023.3 并搭好了 vulhub-master 需要的 docker、docker-compose 等全套环境,然后就没有然后了
几个月后的今天,我终于想起自己还有个 kali 虚拟机,打算开个靶场玩玩
然后就出现了以下问题
┌──(kali㉿kali)-[~]
└─$ docker-compose -v
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 33, in <module>
sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/docker-compose", line 25, in importlib_load_entry_point
return next(matches).load()
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
module = import_module(match.group('module'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1135, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'compose.cli'; 'compose' is not a package
解决方案
去 github 下载 2.x 版本的 : docker-compose
使用 uname -a 或 lsb_release -a 或 cat /etc/os-release查看你的系统版本
kali 请下载 linux-x86_64 后缀的文件
┌──(kali㉿kali)-[~]
└─$ mv docker-compose-linux-x86_64 docker-compose
┌──(kali㉿kali)-[~]
└─$ chmod +x docker-compose
# 先改名改权限
┌──(kali㉿kali)-[~]
└─$ whereis docker-compose
docker-compose: /usr/bin/docker-compose
#不确定的话 先查一下路径
┌──(kali㉿kali)-[~]
└─$ mv /usr/bin/docker-compose /usr/bin/docker-compose.bak
# 如果需要的话 备份一下
┌──(kali㉿kali)-[~]
└─$ mv ./docker-compose /usr/bin/docker-compose
┌──(kali㉿kali)-[~]
└─$ docker-compose --version
Docker Compose version v2.21.0
问题出现的原因
不知道,可能是某次 apt-get update / upgrade 之后没正确重启?
更多推荐
已为社区贡献1条内容
所有评论(0)