I am trying to install the gi package for python3 (it is required for dropbox). I do:
$ sudo apt install python3-gi
python3-gi is already the newest version (3.36.0-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
But when I do:
$ python3 -m gi
/usr/local/bin/python3: No module named gi
I do not use anaconda or virtualenv. How can I install gi correctly?
You have more than one version of Python3 installed.
You are using the wrong Python3.
Here's another way to see it:
$ which -a python3 /usr/bin/python3 <------ Packaged version (correct) /usr/local/bin/python3 <------ Something else you installed (wrong)
Uninstall that non-package /usr/local version of Python 3. How you uninstall it depends upon how you originally installed it (NOT apt). Since we don't know how you installed it, that's up to you.
python3 symlink to point to the correct (packaged) version of Python3. In 20.04, it should point to Python3.8. Here's a 20.04 example of correct Python3 symlinks:
$ ls -l /usr/bin/python3* lrwxrwxrwx 1 root root 9 Mar 13 07:20 /usr/bin/python3 -> python3.8 -rwxr-xr-x 1 root root 5457536 Apr 27 10:53 /usr/bin/python3.8