9

I have been trying to install MPV on my Ubuntu (18.04 LTS). Whenever I am trying to add a PPA repository to my system I get this error.

For example, I tried this:

sudo add-apt-repository ppa:mc3man/mpv-tests

And got this:

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 67, in <module>
    from gi.repository import Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
    from . import _gi
ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)

It happens every time I am trying to add any PPA to my system. I had Python 3.6 installed by default but later updated to Python 3.8.0. I am new to Linux. What might be causing this problem? And How to solve this?

Thank you!

1

2 Answers 2

6

Sounds like your system might have issues choosing the correct Python version.

Try editing the file /usr/bin/add-apt-repository and changing out the line #!/usr/bin/python3 with the specific version of python, in your case:

#!/usr/bin/python3.8

Alternatively see if you have an older working version of python installed that you could use instead:

ls -al /usr/bin | grep python

look for other versions, like python3.5 or python3.6 and try replacing the #!/usr/bin/python3.8 with the apropriate version number.

1

I had the same issue but with python upgraded to 3.7. I found the method from this link: How to install gi for anaconda python3.6 and it works for me. In your situation try to change 3.7 to 3.8 and 37 to 38:

ln -s /usr/lib/python3/dist-packages/gi/ /home/$USER/anaconda3/lib/python3.7/site-packages/
cd /home/$USER/anaconda3/lib/python3.7/site-packages/gi/
sudo cp _gi.cpython-36m-x86_64-linux-gnu.so _gi.cpython-37m-x86_64-linux-gnu.so
sudo cp _gi_cairo.cpython-36m-x86_64-linux-gnu.so _gi_cairo.cpython-37m-x86_64-linux-gnu.so

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .