0

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.

Kwen
  • 107
  • 1
  • 6
  • Does this help you? https://stackoverflow.com/a/7475296/11286032 – Marcelo Paco Mar 16 '23 at 06:21
  • Hello, Thanks for your response. I've already installed `mysql-server` but `libmysqlclient-dev` and `libmariadbclient-dev` packages are not found – Kwen Mar 16 '23 at 06:28
  • Please [don’t post images of code, error messages, or other textual data.](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) Low-contrast images are particularly pesky for some users with disabilities. – tripleee Mar 16 '23 at 06:48
  • Hello, I removed my image – Kwen Mar 16 '23 at 06:57
  • The fact that the answers there do not help for current CentOS do not change the fact that the question has been asked and answered many times. It explains what's wrong and how to troubleshoot the situation. If you solve it for CentOS 9, probably add an answer to the old question and accept the duplicate nomination. – tripleee Mar 16 '23 at 06:58
  • Your image seemed to contain more information, where it tried to install multiple packages before concluding that none of them were available. Or do I misremember? – tripleee Mar 16 '23 at 06:59
  • Hello, the current traceback code is the image that I posted before – Kwen Mar 16 '23 at 07:01
  • https://mariadb.com/kb/en/yum/ has some tips for various RedHat-based distros. https://centos.pkgs.org/9-stream/centos-crb-x86_64/mariadb-devel-10.5.12-3.el9.x86_64.rpm.html seems to indicate that mariadb-devel should be available for CentOS 9 from the standard repositories, though I'm not familiar enough with CentOS to decode all the acronyms there (perhaps CRB is something you can or cannot use, for example?) – tripleee Mar 16 '23 at 07:03
  • Hello, yes you are correct. I was able to solve it. I think the problem is that `mysql-devel ` is no longer supported on the newer versions of CentOS – Kwen Mar 16 '23 at 07:16

1 Answers1

1

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.

Kwen
  • 107
  • 1
  • 6