Install gobject module?

Pip does not have it anymore. Check out the 'Getting Started' section here and install it based on your OS.

For accessibility, based on this question's tags, here's the "Ubuntu" section:

Installing the system provided PyGObject:

  1. Open a terminal
  2. Execute sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0
  3. Change the directory to where your hello.py script can be found (e.g. cd Desktop)
  4. Run python3 hello.py

Installing from PyPI with pip:

  1. Open a terminal and enter your virtual environment
  2. Execute sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 to install the build dependencies and GTK
  3. Execute pip3 install pycairo to build and install Pycairo
  4. Execute pip3 install PyGObject to build and install PyGObject
  5. Change the working directory to where your hello.py script can be found
  6. Run python3 hello.py

Install python3-gi and import it this way

from gi.repository import GObject

or so you don't have to rename all the references

from gi.repository import GObject as gobject