ERROR: Command errored out with exit status 1 mysqlclient
Python

ERROR: Command errored out with exit status 1 mysqlclient

ERROR: Command errored out with exit status 1 mysqlclient: I was installing mysqlclient for my new Django project in my newly installed Ubuntu Linux. And after doing pip install mysqlclient, I got an error of ERROR: Command errored out with exit status 1:

(env) codie@codie-lap:~/Projects/aeck$ pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.0.3.tar.gz (88 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/codie/Projects/aeck/env/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-4_d_xjb9/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-4_d_xjb9/mysqlclient/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-install-4_d_xjb9/mysqlclient/pip-egg-info
         cwd: /tmp/pip-install-4_d_xjb9/mysqlclient/
    Complete output (15 lines):
    /bin/sh: 1: mysql_config: not found
    /bin/sh: 1: mariadb_config: not found
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-4_d_xjb9/mysqlclient/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-4_d_xjb9/mysqlclient/setup_posix.py", line 70, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-4_d_xjb9/mysqlclient/setup_posix.py", line 31, in mysql_config
        raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    mysql_config --version
    mariadb_config --version
    mysql_config --libs
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Also, solve your issue for psycopg2 error install ubuntu

So, how can we fix the issue of /bin/sh: 1: mysql_config: not found or /bin/sh: 1: mariadb_config: not found.

I did some research and after digging the web for 15 minutes, I got the fix for this issue.

Fix ERROR: Command errored out with exit status 1 mysqlclient

To fix the issue of pip install mysqlclient error, you just need to copy the below codes and execute them in your bash-shell.

Install the python3-dev package

python-dev contains the header files that the system needs to build Python extensions. It is used by lxml because it includes Python C extensions for high performance.

sudo apt-get install python3-dev

lxml is a Python C-API extension that is compiled when we run the command pip install lxml.

The lxml sources have at least something like #include <Python.h> in the code. The compiler looks for the header file Python.h during compilation, hence those header files need to be on your system such that they can be found.

Also, solve: Django MySQLClient pip compile failure on Linux

(env) codie@codie-lap:~/Projects/aeck$ sudo apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libssl-dev libssl1.1
Suggested packages:
  libssl-doc
The following NEW packages will be installed:
  libmysqlclient-dev libssl-dev
The following packages will be upgraded:
  libssl1.1
1 upgraded, 2 newly installed, 0 to remove and 107 not upgraded.
Need to get 4,437 kB of archives.
After this operation, 17.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl1.1 amd64 1.1.1f-1ubuntu2.3 [1,320 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl-dev amd64 1.1.1f-1ubuntu2.3 [1,582 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient-dev amd64 8.0.23-0ubuntu0.20.04.1 [1,536 kB]
Fetched 4,437 kB in 5s (921 kB/s)               
Preconfiguring packages ...
(Reading database ... 132596 files and directories currently installed.)
Preparing to unpack .../libssl1.1_1.1.1f-1ubuntu2.3_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1f-1ubuntu2.3) over (1.1.1f-1ubuntu2.1) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_1.1.1f-1ubuntu2.3_amd64.deb ...
Unpacking libssl-dev:amd64 (1.1.1f-1ubuntu2.3) ...
Selecting previously unselected package libmysqlclient-dev.
Preparing to unpack .../libmysqlclient-dev_8.0.23-0ubuntu0.20.04.1_amd64.deb ...
Unpacking libmysqlclient-dev (8.0.23-0ubuntu0.20.04.1) ...
Setting up libssl1.1:amd64 (1.1.1f-1ubuntu2.3) ...
Setting up libssl-dev:amd64 (1.1.1f-1ubuntu2.3) ...
Setting up libmysqlclient-dev (8.0.23-0ubuntu0.20.04.1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

Installing dependency for mysqlclient

Now, you just need to install the dependecy for mysqlclient called libmysqlclient-dev.

sudo apt-get install libmysqlclient-dev

libmysqlclient-dev is a package that provides all the essential dependencies and resources to the system required for the functioning of mysqlclient.

Finally, pip install mysqlclient

Now, you can install mysqlclient with no tension.

pip install mysqlclient
or
pip3 install mysqlclient
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x