title: Cannot install petsc4py on Ubuntu 20.04
body: <p>After successfully installing and testing PETSc I went ahead and tried to install petsc4py with:</p>
  <pre><code>$ sudo python3 -m pip install petsc4py
  </code></pre>
  <p>but got loads of errors. Here are the messages:</p>
  <pre><code>Collecting petsc4py
    Using cached petsc4py-3.16.1.tar.gz (2.3 MB)
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '&quot;'&quot;'/tmp/pip-install-yg5szcfl/petsc4py/setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'/tmp/pip-install-yg5szcfl/petsc4py/setup.py'&quot;'&quot;';f=getattr(tokenize, '&quot;'&quot;'open'&quot;'&quot;', open)(__file__);code=f.read().replace('&quot;'&quot;'\r\n'&quot;'&quot;', '&quot;'&quot;'\n'&quot;'&quot;');f.close();exec(compile(code, __file__, '&quot;'&quot;'exec'&quot;'&quot;'))' egg_info --egg-base /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info
           cwd: /tmp/pip-install-yg5szcfl/petsc4py/
      Complete output (54 lines):
      running egg_info
      creating /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info
      writing /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/dependency_links.txt
      writing requirements to /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/requires.txt
      writing top-level names to /tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/top_level.txt
      writing manifest file '/tmp/pip-install-yg5szcfl/petsc4py/pip-egg-info/petsc4py.egg-info/SOURCES.txt'
      Traceback (most recent call last):
        File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
        File &quot;/tmp/pip-install-yg5szcfl/petsc4py/setup.py&quot;, line 289, in &lt;module&gt;
          main()
        File &quot;/tmp/pip-install-yg5szcfl/petsc4py/setup.py&quot;, line 286, in main
          run_setup()
        File &quot;/tmp/pip-install-yg5szcfl/petsc4py/setup.py&quot;, line 135, in run_setup
          setup(packages     = ['petsc4py',
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/__init__.py&quot;, line 155, in setup
          return distutils.core.setup(**attrs)
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/core.py&quot;, line 148, in setup
          return run_commands(dist)
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/core.py&quot;, line 163, in run_commands
          dist.run_commands()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/dist.py&quot;, line 967, in run_commands
          self.run_command(cmd)
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/dist.py&quot;, line 986, in run_command
          cmd_obj.run()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py&quot;, line 298, in run
          self.find_sources()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py&quot;, line 305, in find_sources
          mm.run()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py&quot;, line 540, in run
          self.add_defaults()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/command/egg_info.py&quot;, line 577, in add_defaults
          sdist.add_defaults(self)
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/command/sdist.py&quot;, line 226, in add_defaults
          self._add_defaults_python()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/command/sdist.py&quot;, line 111, in _add_defaults_python
          build_py = self.get_finalized_command('build_py')
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py&quot;, line 299, in get_finalized_command
          cmd_obj.ensure_finalized()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py&quot;, line 107, in ensure_finalized
          self.finalize_options()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/command/build_py.py&quot;, line 29, in finalize_options
          orig.build_py.finalize_options(self)
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/command/build_py.py&quot;, line 43, in finalize_options
          self.set_undefined_options('build',
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py&quot;, line 287, in set_undefined_options
          src_cmd_obj.ensure_finalized()
        File &quot;/usr/local/lib/python3.8/dist-packages/setuptools/_distutils/cmd.py&quot;, line 107, in ensure_finalized
          self.finalize_options()
        File &quot;/tmp/pip-install-yg5szcfl/petsc4py/conf/baseconf.py&quot;, line 411, in finalize_options
          self.petsc_dir  = config.get_petsc_dir(self.petsc_dir)
        File &quot;/tmp/pip-install-yg5szcfl/petsc4py/conf/baseconf.py&quot;, line 349, in get_petsc_dir
          petsc_dir = petsc.get_petsc_dir()
      AttributeError: module 'petsc' has no attribute 'get_petsc_dir'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  </code></pre>
  <p>There are so many error messages that I have no idea where from I should start. Any help? The installation should be straightforward, I don't know what's going on. Trying to fix the package (or setup.py thereof) manually is futile. I'm using Python 3.8.10.</p>
  <p>Any hints will be much appreciated.</p>