0

I am trying to install mysqlclient package using pip install mysqlclient but keep getting this error as

OSError: mysql_config not found

Collecting mysqlclient
  Using cached mysqlclient-2.0.3.tar.gz (88 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/airflow_env/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-dfln7is0/mysqlclient_696dd7cf04d147ed91836f80c68bc64c/setup.py'"'"'; __file__='"'"'/tmp/pip-install-dfln7is0/mysqlclient_696dd7cf04d147ed91836f80c68bc64c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-l5usa3c5
         cwd: /tmp/pip-install-dfln7is0/mysqlclient_696dd7cf04d147ed91836f80c68bc64c/
    Complete output (15 lines):
    /bin/sh: mysql_config: command not found
    /bin/sh: mariadb_config: command not found
    /bin/sh: mysql_config: command not found
    mysql_config --version
    mariadb_config --version
    mysql_config --libs
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-dfln7is0/mysqlclient_696dd7cf04d147ed91836f80c68bc64c/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-dfln7is0/mysqlclient_696dd7cf04d147ed91836f80c68bc64c/setup_posix.py", line 70, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-dfln7is0/mysqlclient_696dd7cf04d147ed91836f80c68bc64c/setup_posix.py", line 31, in mysql_config
        raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I tried:

  • upgrading setuptools: pip install --upgrade setuptools,
  • installing python-devel, python3-devel, mysql-devel
  • installing mariadb: yum install mariadb-devel gives error
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-devel-5.5.68-1.el7.x86_64
--> Processing Dependency: openssl-devel(x86-64) for package: 1:mariadb-devel-5.5.68-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be installed
---> Package openssl-devel.x86_64 1:1.0.2k-21.el7_9 will be installed
--> Processing Dependency: zlib-devel(x86-64) for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.15.1-50.el7 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-50.el7 for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-50.el7.x86_64
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed
---> Package libkadm5.x86_64 0:1.15.1-50.el7 will be installed
---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-15.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
--> Running transaction check
---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
Removing mariadb-libs.x86_64 1:5.5.68-1.el7 - u due to obsoletes from installed mysql-community-libs-8.0.22-1.el7.x86_64
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-devel-5.5.68-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: 1:mariadb-devel-5.5.68-1.el7.x86_64 (base)
           Requires: mariadb-libs(x86-64) = 1:5.5.68-1.el7
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

I am using centos7: CentOS Linux release 7.9.2009 (Core)

I tried this using docker container in centos7 and did not face any issue.

AnupaM
  • 187
  • 2
  • 2
  • 8
  • 1
    [mysql_config not found when installing mysqldb python interface](https://stackoverflow.com/questions/7475223/mysql-config-not-found-when-installing-mysqldb-python-interface) ? – Luuk Jan 21 '21 at 11:55
  • 1
    Does this answer your question? [mysql\_config not found when installing mysqldb python interface](https://stackoverflow.com/questions/7475223/mysql-config-not-found-when-installing-mysqldb-python-interface) – Shadow Jan 21 '21 at 12:40
  • I am afraid, this did not work for me. – AnupaM Jan 21 '21 at 13:25

1 Answers1

1

As @Luuk stated inside the comments you are trying to install an interface to mysql with your pip command rather than sql itself. That is why you are getting the following OSError

>>> OSError: mysql_config not found

First you should install mariadb as explained in their webpage that is

$ sudo yum install mariadb-server

and afterwards run the set of commands

$ sudo yum install python3-devel mysql-devel
$ pip install mysqlclient

Also note that everything runs correctly inside your docker container because it acts like a separate machine.

Diego Asterio
  • 111
  • 1
  • 9
  • Yeah, you should have flagged it as a duplicate, rather than answering it again. – Shadow Jan 21 '21 at 12:41
  • I tried installing mariadb-server and python3-devel, as you mentioned, but I am still facing same problem while installing `mysql-devel`: ```Error: Package: 1:mariadb-devel-5.5.68-1.el7.x86_64 (base) Requires: mariadb-libs(x86-64) = 1:5.5.68-1.el7``` – AnupaM Jan 21 '21 at 13:24