맨날 까먹는데, 해법이 너무 옛날 것들이 검색됨.
venv환경에서 이를 해결보려면...
https://stackoverflow.com/questions/48617779/virtualenv-importerror-no-module-named-mysqldb
VirtualEnv ImportError: No module named MySQLdb
I am receiving the error: ImportError: No module named MySQLdb whenever I try to run my local dev server and it is driving me crazy. I have tried everything I could find online: brew install mysql...
stackoverflow.com
sudo apt-get install python3-mysqldb
sudo apt-get install libmysqlclient-dev
pip install mysqlclient
이렇게 하면 됨.
MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory
46 | #include "Python.h"
| ^~~~~~~~~~
이거는 python3.10-dev 도 깔아야 해결됨.
2025-08-21
Resolved 38 packages in 89ms
× Failed to build `mysqlclient==2.2.7`
├─▶ The build backend returned an error
╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)
[stdout]
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.
Trying pkg-config --exists libmariadb
Command 'pkg-config --exists libmariadb' returned non-zero exit status 127.
Trying pkg-config --exists perconaserverclient
Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 127.
[stderr]
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
requires = get_requires_for_build({})
File
"/home/oms/.cache/uv/builds-v0/.tmpBhGwk4/lib/python3.13/site-packages/setuptools/build_meta.py",
line 331, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/oms/.cache/uv/builds-v0/.tmpBhGwk4/lib/python3.13/site-packages/setuptools/build_meta.py",
line 301, in _get_build_requires
self.run_setup()
~~~~~~~~~~~~~~^^
File
"/home/oms/.cache/uv/builds-v0/.tmpBhGwk4/lib/python3.13/site-packages/setuptools/build_meta.py",
line 317, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 156, in <module>
File "<string>", line 49, in get_config_posix
File "<string>", line 28, in find_package_name
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
hint: This usually indicates a problem with the package or the build environment.
요새는 build-essential 패키지를 깔아도 pkg-config가 설치되지 않아서 컴파일이 안 되기도 함.
sudo apt install pkgconf
로 pkg-config 프로그램을 설치하자.