Ubuntu error Django part3 : Running Backgroud task lecture#5

pip install mysqlclient Installation error in ubuntu. After following the steps in the pdf file Running Django on WSL when I enter

pip install mysqlclient
I get this error:
Defaulting to user installation because normal site-packages is not writeable
Collecting mysqlclient
Using cached mysqlclient-2.2.0.tar.gz (89 kB)
Installing build dependencies … done
Getting requirements to build wheel … error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Trying pkg-config --exists mysqlclient
Command ‘pkg-config --exists mysqlclient’ returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command ‘pkg-config --exists mariadb’ returned non-zero exit status 127.
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 363, in
main()
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 345, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File “/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py”, line 130, in get_requires_for_build_wheel
return hook(config_settings)
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 162, in get_requires_for_build_wheel
return self._get_build_requires(
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 143, in _get_build_requires
self.run_setup()
File “/usr/lib/python3/dist-packages/setuptools/build_meta.py”, line 158, in run_setup
exec(compile(code, file, ‘exec’), locals())
File “setup.py”, line 154, in
ext_options = get_config_posix(get_options())
File “setup.py”, line 48, in get_config_posix
pkg_name = find_package_name()
File “setup.py”, line 27, in find_package_name
raise Exception(
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

1 Like

I got the same error messages too when I ran the code. I did some searches online (Stack Overflow) and I was able to resolve them by running the below steps.
To fix, run
i. sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
ii. pip install mysqlclient
iii. The first two steps should work. If it doesn’t, run sudo apt install pkg-config This should fix it.

1 Like