When deploying my app, I get this error while trying to install mysqlclient:
Exception: Can not find valid pkg-config name. Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
I don’t want to have to set these vars manually but would prefer to install pkg-config on my Windows computer. I downloaded the w64devkit from Releases · skeeto/w64devkit · GitHub and placed the files off the root like this: C:\w64devkit\bin\pkg-config.exe and then added this location to the PATH variable but this did not work.
When I check to see the version number it shows 0.31.1:
Why can’t the build process locate the pkg-config file? I must be doing something wrong. Any suggestions?
As for the environment variable name, not sure if PATH is the only environment variable that it may refer to. Could you verify that the PATH variable contains the path:
echo %PATH%
Alternatively, there seems to be a Python package called pykg-config that serves as a Python drop-in replacement for pkg-config.
I see a reference to /bin/sh but I don’t know what that is referring to. Although I was able to install the pykg--config package without error, that did not resolve the problem I am still having with the mysqlclient installation process during deployment.
Perhaps it is not necessary for me to list mysqlclient in the requirements.txt file. When I do pip install mysqlclient it tells me ‘Requirement already satisfied…’:
Looking at the README page of mysqlclient (https://github.com/PyMySQL/mysqlclient/blob/main/README.md) indicated that you’ll need to have the DB connector installed in addition to mysqlclient. Please see if you can either download a binary version for use as building one seems to be a bit buggy (in reference to the above README page.
As for the pkg-config not being found at /bin/sh which seems odd as you’re using a Windows and the mentioned path seems to be Linux based. Getting the environment path right on Windows also seem to be a rabbit hole in itself as the pre-defined default path is not clearly stated. Thus, the next steps would be to try the above installation of the DB connector.
If the above does not work, I think it may be easier to start fresh by using a package manager like conda (I’d prefer mini-conda as it has a light footprint on the computer) where you can install a fresh Python installation for a new conda environment, that way all dependencies will be handled by conda.
Not quite sure if this helps, but it is the thought process of how I would approach the problem.
Thanks for your ideas Chanin. I was able to download the MariaDB C Connector and install it, but that didn’t seem to make any difference as I still get the same errors with the mysqlclient install failing because pkg-config not found.
I then decided to try your suggestion of using Miniconda3. I was able to get both the DB connector and the DB client packages installed as seen here:
Both of these package installs completed successfully but when I rebooted my Streamlit app I still keep getting the same error about pkg-config: not found
I noticed that the error message is still mentioning the /bin/sh: path which is not where the DB Connector and DB Client were installed using miniconda3. They appear to have been installed in: pkgs/main/win-64::
How can I update the Streamlit app to look in the right place for the required packages (DB Connector, DB Client, pkg-config) that have now been successfully installed using miniconda3 ?
p.s. I am wondering whether doing the command conda install mysqlclient needs to be done from the project directory? I don’t think so, and didn’t do that in my test discussed above.
I hope this makes at least some sense. I’m tired and need to sleep now. Looking forward to hearing your thoughts… again.
Thanks for the update and sounds like we’re making some progress. It seems from the screenshot that you’re using Python 3.7 and starting from Streamlit 1.24.0 it requires at least 3.8 as 3.7 is no longer supported. Also have you tried following the tutorial on setting up a MySQL connecting with Streamlit:
The above tutorial seems to require
SQLAlchemy
and you can now use st.experimental_connection for connecting to the database.
Sorry to hear that it is still not working. Would you like to share the code repo to your app. This is the best way to allow the reproduction of the error.
One final update for anyone following along. I managed to resolve this issue by switching from mysqlclient to pymysql in the requirements.txt file. I also added this line to my connections credential information: driver = "pymysql" as shown here:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.