简体   繁体   中英

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

I am Debian user.

I run the code in the shell as a root:

I want to install telegram with below command :

sudo add-apt-repository ppa:atareao/telegram

sudo apt-get update

sudo apt-get install telegram

I get the following error:

    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'

how can I resolve it?

Thanks

Tow way to install telegram on debian:

1) The telegram package can be installed through snap .

# apt install snapd

To find a package:

snap find telegram

Sample output:

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

To install telegram :

# snap install telegram-desktop

2) The package telegram-desktop is available on stretch-backports . Edit your /etc/apt/sources.list by adding the following line:

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

Save then run:

# apt update
# apt install telegram-desktop

The package is available also for debian Buster and Sid.

Remove the ppa:atareao/telegram (Under /etc/apt/sources.list.d/ ) and see the answer linked by @aicastell to fix the error.

why you want to download and install telegram from PPA ?!
follow me :
1) Download Telegram Desktop from Telegram.Org
2) Extract archive to /opt
3) execute /opt/Telegram/Telegram

Note : Telegram app automatically install telegramdesktop.desktop file on your application menu (~/.local/share/applications/telegramdesktop.desktop) . next time only click on icon .

FINE .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM