Unable to install project on Linux - mysqlclient error

Hi guys.

I am moving my development environment from Windows to Linux Mint, and when trying to install my project with pipenv install (after pipenv shell), mysqlclient keeps failing to install. See terminal output below.

I have tried many different solutions from Stack Overflow and tried running these scripts from Medium, but nothing works.

I have MySQL server running with DataGrip connected to it, so at least this is working.

Hopefully one of you can help me.

Thank you!

Expand to see terminal output
(Project_Odin) sh-5.3$ pipenv install
Pipfile.lock (8884e43f5a7adef0643badab3a9add1df0c36929f8375d7036f4b7068e90beb0) out of date: run `pipenv lock` 
to update to (ba29abcb34cfda97d8d764bfa7b573e5654a59219d303a97b55f4c383a734074)...
Locking  dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking  dependencies...
Updated Pipfile.lock (ba29abcb34cfda97d8d764bfa7b573e5654a59219d303a97b55f4c383a734074)!
Installing dependencies from Pipfile.lock (734074)...
(Project_Odin) sh-5.3$ pipenv install mysqlclient
Installing mysqlclient...
✔ Installation Succeeded
Installing dependencies from Pipfile.lock (734074)...
All dependencies are now up-to-date!
Upgrading mysqlclient in  dependencies.
Building requirements...
Resolving dependencies...
✘ Locking Failed!
⠏ Locking packages...ERROR:pip.subprocessor:Getting requirements to build wheel exited with 1
Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
You can use $ pipenv run pip install <requirement_name> to bypass this mechanism, then run $ pipenv graph to 
inspect the versions actually installed in the virtualenv.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
Hint: The error 'Getting requirements to build wheel' often indicates:
  • Invalid pyproject.toml syntax or configuration
  • Encoding issues in files referenced by pyproject.toml (e.g., README.md with special characters)
  • Missing or incompatible build dependencies
Try running $ pip install . -v for more detailed error output.
ERROR: Failed to build 'mysqlclient' when getting requirements to build wheel

Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
You can use $ pipenv run pip install <requirement_name> to bypass this mechanism, then run $ pipenv graph to 
inspect the versions actually installed in the virtualenv.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Failed to lock Pipfile.lock!
(Project_Odin) sh-5.3$ pipenv run pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.7.tar.gz (91 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      Trying pkg-config --exists mysqlclient
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
      Trying pkg-config --exists mariadb
      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
      Trying pkg-config --exists libmariadb
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
      Trying pkg-config --exists perconaserverclient
      Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 1.
      Traceback (most recent call last):
        File "/home/daniel/.var/app/com.vscodium.codium/data/virtualenvs/Project_Odin-oc8Ww2y_/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
          ~~~~^^
        File "/home/daniel/.var/app/com.vscodium.codium/data/virtualenvs/Project_Odin-oc8Ww2y_/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/daniel/.var/app/com.vscodium.codium/data/virtualenvs/Project_Odin-oc8Ww2y_/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-d51nzd2x/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-d51nzd2x/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/tmp/pip-build-env-d51nzd2x/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 156, in <module>
        File "<string>", line 49, in get_config_posix
        File "<string>", line 28, in find_package_name
      Exception: Can not find valid pkg-config name.
      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'mysqlclient' when getting requirements to build wheel
(Project_Odin) sh-5.3$ pipenv lock --pre
Locking  dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking  dependencies...
Updated Pipfile.lock (ba29abcb34cfda97d8d764bfa7b573e5654a59219d303a97b55f4c383a734074)!
(Project_Odin) sh-5.3$ pipenv run pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.7.tar.gz (91 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      Trying pkg-config --exists mysqlclient
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
      Trying pkg-config --exists mariadb
      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
      Trying pkg-config --exists libmariadb
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
      Trying pkg-config --exists perconaserverclient
      Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 1.
      Traceback (most recent call last):
        File "/home/daniel/.var/app/com.vscodium.codium/data/virtualenvs/Project_Odin-oc8Ww2y_/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
          ~~~~^^
        File "/home/daniel/.var/app/com.vscodium.codium/data/virtualenvs/Project_Odin-oc8Ww2y_/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/daniel/.var/app/com.vscodium.codium/data/virtualenvs/Project_Odin-oc8Ww2y_/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-ierixvk8/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ierixvk8/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/tmp/pip-build-env-ierixvk8/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 156, in <module>
        File "<string>", line 49, in get_config_posix
        File "<string>", line 28, in find_package_name
      Exception: Can not find valid pkg-config name.
      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'mysqlclient' when getting requirements to build wheel