Can't install Telegram on Debian : ModuleNotFoundError: No module named 'apt_pkg'

Can't install Telegram on Debian : ModuleNotFoundError: No module named 'apt_pkg'

我是 Debian 用户。

我运行中的代码shell作为根:

我想用下面的命令安装电报:

sudo add-apt-repository ppa:atareao/telegram

sudo apt-get update

sudo apt-get install telegram

我收到以下错误:

    Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

我该如何解决?

谢谢

在 debian 上安装 telegram 的两种方法:

1) telegram 包可以通过 snap.

安装
# apt install snapd

查找包裹:

snap find telegram

示例输出:

Name                 Version     Developer       Notes  Summary
telegram-sergiusens  1.2.6       sergiusens      -      Telegram desktop client
telegram-cli         1.4.5       marius-quabeck  -      Command-line interface for Telegram. Uses the readline interface.
telegram-desktop     1.2.17      3v1n0           -      Official desktop client for the Telegram messenger
ubuntu-social-kit    3           keshavnrj       -      Bring social media apps to Ubuntu Desktop
squirrelbot          1.1.2       xordspar0       -      A Telegram bot that stashes away links that you send it
mup-plugins          2017.04.19  niemeyer        -      mup IRC and Telegram bot - plugins side
mup-accounts         2016.09.24  niemeyer        -      mup IRC and Telegram bot - account connection side
shell2telegram       1.7         msoap           -      Telegram bot constructor from command-line

安装telegram:

# snap install telegram-desktop

2) telegram-desktop 包在 stretch-backports 上可用。通过添加以下行来编辑您的 /etc/apt/sources.list

deb http://deb.debian.org/debian/ stretch-backports main

然后保存 运行:

# apt update
# apt install telegram-desktop

该软件包也可用于 debian Buster 和 Sid。

删除 ppa:atareao/telegram(在 /etc/apt/sources.list.d/ 下)并查看由 @aicastell 链接的 the answer 以修复错误。

为什么要从 PPA 下载并安装电报?!
跟我来 :
1)Telegram.Org
下载 Telegram 桌面版 2) 将存档解压到 /opt
3)执行/opt/Telegram/Telegram

注意:Telegram 应用程序会自动在您的应用程序菜单 (~/.local/share/applications/telegramdesktop.desktop) 上安装 telegramdesktop.desktop 文件。下次只需单击图标。

很好。