[英]ModuleNotFoundError: No module named 'apt_pkg' installing deadsnakes repository
I want to install Python 3.10 on Ubuntu 18.04 (I'm currently on Python 3.8) from the deadsnakes repository with the following set of commands I found on the internet:我想使用我在互联网上找到的以下命令集从 deadsnakes 存储库在 Ubuntu 18.04(我目前使用的是 Python 3.8)上安装 Python 3.10:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
But I got the error sudo: add-apt-repository: command not found
.但是我收到错误
sudo: add-apt-repository: command not found
。
More net research led me to this set of commands at "ModuleNotFoundError: No module named 'apt_pkg'" appears in various commands - Ask Ubuntu :更多的网络研究使我在“ModuleNotFoundError: No module named 'apt_pkg'”出现在各种命令中 - 问 Ubuntu :
sudo apt remove python3-apt
sudo apt autoremove
sudo apt autoclean
sudo apt install python3-apt
Other web sources said the same thing, so I did that, but I still get the error message when I run sudo add-apt-repository ppa:deadsnakes/ppa
.其他网络资源也说了同样的话,所以我就这样做了,但是当我运行
sudo add-apt-repository ppa:deadsnakes/ppa
时,我仍然收到错误消息。
Then I found How to Fix 'add-apt-repository command not found' on Ubuntu & Debian - phoenixNAP , which advised this set of commands:然后我找到了 How to Fix 'add-apt-repository command not found' on Ubuntu & Debian - phoenixNAP ,它建议这组命令:
sudo apt update
sudo apt install software-properties-common
sudo apt update
so I did that, but when I run sudo add-apt-repository ppa:deadsnakes/ppa
I now get this error message:所以我这样做了,但是当我运行
sudo add-apt-repository ppa:deadsnakes/ppa
时,我现在收到此错误消息:
~$ sudo add-apt-repository ppa:deadsnakes/ppa
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 12, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 28, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I have found some web links that show a wide variety of solutions with earlier versions of Python.我找到了一些 Web 链接,这些链接显示了使用早期 Python 版本的各种解决方案。 I'm currently on Python 3.8.
我目前使用的是 Python 3.8。
Before I do anything more I want to ask what is the best way to solve the ModuleNotFoundError: No module named 'apt_pkg'
error message when trying to install the deadsnakes repository to install Python 3.10, given the number of possible solutions I have seen.在我做更多事情之前,我想问解决
ModuleNotFoundError: No module named 'apt_pkg'
错误消息,考虑到我已经看到的可能解决方案的数量。
Thanks very much.非常感谢。
This worked for me:这对我有用:
sudo apt-get install python3-apt --reinstall
cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so
The 38 in the filename above can be different for you.上面文件名中的 38 可能与您不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.