Unable to start services due to git problem

I installed erpnext inside a python virtual environment on FreeBSD.
The services are refusing to start and are giving me the errors below.
I already tried by setting the following in ~/.bash_profile:

export CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1
export GIT_PYTHON_REFRESH=quiet
export GIT_PYTHON_GIT_EXECUTABLE=/usr/local/bin/git

worker.error.log:

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 5, in <module>
    from bench.cli import cli
  File "/usr/local/lib/python3.11/site-packages/bench/cli.py", line 14, in <module>
    from bench.bench import Bench
  File "/usr/local/lib/python3.11/site-packages/bench/bench.py", line 36, in <module>
    from bench.utils.app import get_current_version
  File "/usr/local/lib/python3.11/site-packages/bench/utils/app.py", line 17, in <module>
    from bench.app import get_repo_dir
  File "/usr/local/lib/python3.11/site-packages/bench/app.py", line 17, in <module>
    import git
  File "/usr/local/lib/python3.11/site-packages/git/__init__.py", line 298, in <module>
    raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh(<full-path-to-git-executable>)

All git commands will error until this is rectified.

This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|silent|none|n|0: for no message or exception
    - warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)
    - error|e|exception|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

schedule.errr.log:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1442, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1363, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1830, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1827, in invoke
    super().invoke(ctx)
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1226, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 794, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 44, in app_group
    ctx.obj = {"sites": get_sites(site), "force": force, "verbose": verbose, "profile": profile}
                        ^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 56, in get_sites
    elif default_site := frappe.get_conf().default_site:
                         ^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 406, in get_conf
    with init_site(site):
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 416, in __enter__
    init(self.site)
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 228, in init
    local.conf = _dict(get_site_config())
                       ^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 364, in get_site_config
    os.environ.get("FRAPPE_DB_PORT") or config.get("db_port") or db_default_ports(config["db_type"])
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 347, in db_default_ports
    from frappe.database.mariadb.database import MariaDBDatabase
  File "/opt/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 4, in <module>
    import pymysql
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/__init__.py", line 79, in <module>
    from . import connections  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/connections.py", line 13, in <module>
    from . import _auth
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/_auth.py", line 10, in <module>
    from cryptography.hazmat.primitives import serialization, hashes
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/cryptography/hazmat/primitives/serialization/__init__.py", line 7, in <module>
    from cryptography.hazmat.primitives._serialization import (
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/cryptography/hazmat/primitives/_serialization.py", line 10, in <module>
    from cryptography.hazmat.primitives.hashes import HashAlgorithm
  File "/opt/frappe/frappe-bench/env/lib/python3.11/site-packages/cryptography/hazmat/primitives/hashes.py", line 9, in <module>
    from cryptography.hazmat.bindings._rust import openssl as rust_openssl
RuntimeError: OpenSSL 3.0's legacy provider failed to load. This is a fatal error by default, but cryptography supports running without legacy algorithms by setting the environment variable CRYPTOGRAPHY_OPENSSL_NO_LEGACY. If you did not expect this error, you have likely made a mistake with your OpenSSL configuration.