$ etcdctl
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'.
我试图看看 etcdctl 是否有效。我也尝试过这个:https://stackoverflow.com/questions/41986507/unable-to-set-default-python-version-to-python3-in-ubuntu#:~:text=Type%20alias%20python%3Dpython3%20on,your%20alias %20应该%20是%20永久。
答案1
根据这些答案:
- https://stackoverflow.com/questions/69949591/modulenotfounderror-no-module-named-apt-pkg-installing-deadsnakes-repository
- https://stackoverflow.com/questions/13708180/python-dev-installation-error-importerror-no-module-named-apt-pkg
我尝试了以下方法,它似乎有效:
- 使用以下命令查找相关
apt_pkg
文件:ls /usr/lib/python3/dist-packages/*apt_pkg*
- 建立必要的符号链接。以我为例,它是:
sudo ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so