Never works! Add dependencies to your requirements file Add the mysqlclient and SQLAlchemy packages to your requirements.txt file,

I am trying to connect streamlit app to Google Cloud mysql instance, and was Never able to do so. The issue is mysqlclient installation ALWAYS failed.
I followed the standard instruction here:

Add dependencies to your requirements file

Add the mysqlclient and SQLAlchemy packages to your requirements.txt file, preferably pinning its version (replace x.x.x with the version you want installed):

Please can you link to your repository and share your complete logs that describe the failure?

──────────────────────────────────────── uv ───────────────────────────────────────────

Using uv pip install.
Resolved 154 packages in 83ms
error[2024-11-04 04:32:10.185767] : Failed to download distributions
  Caused by: Failed to fetch wheel: mysqlclient==2.2.5
  Caused by: Failed to build: `mysqlclient==2.2.5`
  Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit status: 1
--- stdout:
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 127.
Trying pkg-config --exists libmariadb
Command 'pkg-config --exists libmariadb' returned non-zero exit status 127.
Trying pkg-config --exists perconaserverclient
Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 127.
--- stderr:
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "/home/adminuser/.cache/uv/.tmp3QW1nT/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adminuser/.cache/uv/.tmp3QW1nT/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires
    self.run_setup()
  File "/home/adminuser/.cache/uv/.tmp3QW1nT/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 319, in run_setup
    exec(code, locals())
  File "<string>", line 155, 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
---
Checking if Streamlit is installed
Found Streamlit version 1.39.0 in the environment

────────────────────────────────────────────────────────────────────────

Add pkg-config to your packages.txt. You might need to add the other dependencies mentioned in the installation instructions too:

python3-dev
default-libmysqlclient-dev
build-essential
pkg-config

I would install them as the error messages tell me that I really need them, but that is probably just my way of being parsimonious.

1 Like

Thanks Goyo, your idea is the solution. Now I am able to connect mysql. MAHALO

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.