Error installing from pip

I tried to install using pip but get the following error:

Building wheels for collected packages: pygit2
  Building wheel for pygit2 (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/tmpejd6451n build_wheel /tmp/tmplckc4qk2
       cwd: /tmp/pip-install-job0xm4o/pygit2
  Complete output (66 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-cpython-38
  creating build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/_run.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/credentials.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/callbacks.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/_build.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/remote.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/submodule.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/ffi.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/settings.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/repository.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/blame.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/index.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/config.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/refspec.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/utils.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/__init__.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/packbuilder.py -> build/lib.linux-x86_64-cpython-38/pygit2
  copying pygit2/errors.py -> build/lib.linux-x86_64-cpython-38/pygit2
  creating build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/diff.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/blame.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/refspec.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/config.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/graph.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/types.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/index.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/indexer.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/oid.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/common.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/buffer.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/repository.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/net.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/remote.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/describe.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/pack.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/clone.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/strarray.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/transport.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/checkout.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/errors.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/submodule.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/revert.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/merge.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/callbacks.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/stash.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/proxy.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/attr.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/decl/commit.h -> build/lib.linux-x86_64-cpython-38/pygit2/decl
  copying pygit2/_pygit2.pyi -> build/lib.linux-x86_64-cpython-38/pygit2
  running build_ext
  generating cffi module 'build/temp.linux-x86_64-cpython-38/pygit2._libgit2.c'
  creating build/temp.linux-x86_64-cpython-38
  building 'pygit2._pygit2' extension
  creating build/temp.linux-x86_64-cpython-38/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/include -I/usr/include/python3.8 -c src/blob.c -o build/temp.linux-x86_64-cpython-38/src/blob.o
  In file included from src/diff.h:34,
                   from src/blob.c:30:
  src/types.h:36:2: error: #error You need a compatible libgit2 version (1.5.x)
     36 | #error You need a compatible libgit2 version (1.5.x)
        |  ^~~~~
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for pygit2
Failed to build pygit2
ERROR: Could not build wheels for pygit2 which use PEP 517 and cannot be installed directly

This is on Mint linux 20.3 (which is a derivative of Ubuntu 20.04.5 LTS (Focal Fossa).

I have the following version of libgit2-dev installed:

$ apt show libgit2-dev 
Package: libgit2-dev
Version: 0.28.4+dfsg.1-2
Priority: extra
Section: universe/libdevel
Source: libgit2
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Utkarsh Gupta <utkarsh@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 3,204 kB
Depends: libgit2-28 (= 0.28.4+dfsg.1-2), zlib1g-dev, libmbedtls-dev, libssh2-1-dev, libhttp-parser-dev
Homepage: https://libgit2.github.com/
Download-Size: 691 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Description: low-level Git library (development files)
 libgit2 is a portable, pure C implementation of the Git
 distributed version control system core methods provided as a
 re-entrant link-able library with a solid API.
 .
 This package contains the development files for libgit2.