I'm currently setting-up an existing Django project using a virtual environment with Python3.9 on my CentOS system.
When I ran the pip install requirements.txt
command it gets stuck on installing mysqlclient and shows an error: OSError: mysql_config not found
.
ERROR: Command errored out with exit status 1:
command: /home/test/Projects/env/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-of5a4s4j/mysqlclient_d1bfd0ee1acb4132874cf63635277f3e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-of5a4s4j/mysqlclient_d1bfd0ee1acb4132874cf63635277f3e/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-0xsnkncd
cwd: /tmp/pip-install-of5a4s4j/mysqlclient_d1bfd0ee1acb4132874cf63635277f3e/
Complete output (10 lines):
/bin/sh: line 1: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-of5a4s4j/mysqlclient_d1bfd0ee1acb4132874cf63635277f3e/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-install-of5a4s4j/mysqlclient_d1bfd0ee1acb4132874cf63635277f3e/setup_posix.py", line 47, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-install-of5a4s4j/mysqlclient_d1bfd0ee1acb4132874cf63635277f3e/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
I also tried installing the required prerequisites for as mentioned in https://pypi.org/project/mysqlclient/
dnf install python3-devel
command and other requirements such as gcc
works fine but it shows an Error for
dnf install mysql-devel
The error shows:
No match for argument: mysql-devel
Error: Unable to find a match: mysql-devel
So far, I tried the following commands:
dnf install mysql-devel
dnf install mysql-community-devel
dnf install mariadb-devel
dnf install libmysqlclient-dev
dnf install libmariadbclient-dev
But no luck.
dnf install mysql-server is already installed
Just for the record, I have tried all the answers from other posts but almost all of their answers were
yum install python-devel mysql-devel
which was not working for me.
I was able to solve it by checking all the packages that CentOS provides by using dnf provides mysql_config
It will list all the available packages that provides mysql_config. When I did this there were 4 results shown
mariadb-connector-c-devel-3.1.13-3.el9.i686 : Development files for mariadb-connector-c Repo : appstream Matched from: Filename : /usr/bin/mysql_config
mariadb-connector-c-devel-3.1.13-3.el9.x86_64 : Development files for mariadb-connector-c Repo : appstream Matched from: Filename : /usr/bin/mysql_config
mariadb-connector-c-devel-3.2.6-1.el9.i686 : Development files for mariadb-connector-c Repo : appstream Matched from: Filename : /usr/bin/mysql_config
mariadb-connector-c-devel-3.2.6-1.el9.x86_64 : Development files for mariadb-connector-c Repo : appstream Matched from: Filename : /usr/bin/mysql_config
In my case, I selected mariadb-connector-c-devel-3.2.6-1.el9.x86_64
so i installed it using dnf dnf install mariadb-connector-c-devel-3.2.6-1.el9.x86_64
Afterwards I was able to install mysqlclient properly.
I think the problem is that mysql-devel
is no longer supported on the newer versions of CentOS
Thanks for your help everyone.