0

I was trying to add a ppa using the command

sudo add-apt-repository ppa:nathan-renniewaldock/flux

I got the following error.

panda123@panda123:~$ sudo add-apt-repository ppa:nathan-renniewaldock/flux
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'

When I ran ls -l /usr/lib/python3/dist-packages/apt_pkg*, I got the following output.

panda123@panda123:~$ ls -l /usr/lib/python3/dist-packages/apt_pkg*
lrwxrwxrwx 1 root root     39 Jul 27 18:47 /usr/lib/python3/dist-packages/apt_pkg.cpython-34m-x86_64-linux-gnu.so -> apt_pkg.cpython-35m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 310268 May 21 19:50 /usr/lib/python3/dist-packages/apt_pkg.cpython-35m-i386-linux-gnu.so
lrwxrwxrwx 1 root root     39 Jul 27 18:49 /usr/lib/python3/dist-packages/apt_pkg.so -> apt_pkg.cpython-36m-x86_64-linux-gnu.so

running python -V gives me the following output

panda123@panda123:~$ python -V
Python 2.7.12
  • What do you get with `python3 -V` – guiverc Jul 28 '20 at 01:46
  • @guiverc Python 3.7.8 – Shweta Aggrawal Jul 28 '20 at 01:47
  • @guiverc everything got messed up since I installed python3 two days ago. Can you please tell me what to do? – Shweta Aggrawal Jul 28 '20 at 01:49
  • 1
    You've changed your default python, so tools that rely on the default python3 (3.6.5) will no longer work until you reverse whatever you've done. Revert your changes, and if you need to use later python3 for something, do it properly (`update-alternatives`) FYI: Python3 is installed by default in Ubuntu 16.04 LTS; it didn't need to be installed – guiverc Jul 28 '20 at 01:53
  • @guiverc asking a stupid question., is there a quick way to revert everything back to what it earlier was. I don't have much knowledge of how to play with linux. Thanks. – Shweta Aggrawal Jul 28 '20 at 01:56
  • Why as you asking me about whatever backup strategy you've put in place? Your command `history` will show your commands, and `apt` logs (`/var/log/apt/history.log`) will show package changes made via apt/dpkg & like commands. However you'll find many higher-level tools (those that use the default python3) may not work so you'll need to use lower level (non-python) tools, but I'd start by refreshing your memory of what you did via history & logs. – guiverc Jul 28 '20 at 02:22
  • Does this answer your question? [Problem with update-manager: No module named 'apt\_pkg' in Ubuntu 13.10, having installed Python 3.4 on /usr/local/lib](https://askubuntu.com/questions/480908/problem-with-update-manager-no-module-named-apt-pkg-in-ubuntu-13-10-having-i) – karel Aug 29 '20 at 11:14

0 Answers0