Solution 1:

python-gi, python-cairo, and python3-gi-cairo packages are not available in the default Ubuntu 21.04 repositories. Install python-gi, python-cairo, and python3-gi-cairo from Ubuntu 20.04 in Ubuntu 21.04. After that, install gir1.2-goocanvas-2.0, python3-gi, python3-gi-cairo, python3-pygraphviz, gir1.2-gtk-3.0, and ipython3.

Open the terminal and type:

wget -c http://mirrors.kernel.org/ubuntu/pool/universe/p/pygobject/python-gi_3.36.0-1_amd64.deb http://mirrors.kernel.org/ubuntu/pool/universe/p/pycairo/python-cairo_1.16.2-2ubuntu2_amd64.deb http://mirrors.kernel.org/ubuntu/pool/universe/p/pygobject/python-gi-cairo_3.36.0-1_amd64.deb
sudo apt update   
sudo apt install python2   
sudo apt install ./python-gi_3.36.0-1_amd64.deb 
sudo apt install ./python-cairo_1.16.2-2ubuntu2_amd64.deb
sudo apt install ./python-gi-cairo_3.36.0-1_amd64.deb
sudo apt install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3