Collecting mysqlclient==2.1.1 Using cached mysqlclient-2.1.1.tar.gz (88 kB) ERROR: Command errored out with exit status 1:

2023. 9. 18. 12:57python

CCollecting mysqlclient==2.1.1
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
ERROR: Command errored out with exit status 1:
command: /home/cfdc010/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q63vxu4v/mysqlclient/setup.py'"'"'; file='"'"'/tmp/pip-install-q63vxu4v/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-q63vxu4v/mysqlclient/pip-egg-info
cwd: /tmp/pip-install-q63vxu4v/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 "", line 1, in
File "/tmp/pip-install-q63vxu4v/mysqlclient/setup.py", line 15, in
metadata, options = get_config()
File "/tmp/pip-install-q63vxu4v/mysqlclient/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-q63vxu4v/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.

이 문제는 mysqlclient Python 패키지가 시스템에서 필요한 MySQL 또는 MariaDB 개발 라이브러리와 헤더를 찾지 못해서 발생하는 것입니다. 구체적으로, 패키지는 MySQL 또는 MariaDB 설치에 관한 정보를 제공하는 mysql_configmariadb_config라는 유틸리티를 찾을 수 없습니다.

이 문제를 해결하려면, 사용 중인 데이터베이스에 따라 MySQL 또는 MariaDB 개발 패키지를 설치해야 합니다. 아래에서 어떻게 해야 하는지 설명하겠습니다.

MySQL의 경우:

  1. MySQL 개발 라이브러리와 헤더를 설치합니다. Ubuntu/Debian에서는 다음 명령을 사용할 수 있습니다.

    sudo apt-get install libmysqlclient-dev

    CentOS/RHEL에서는 다음 명령을 사용합니다.

    sudo yum install mysql-devel

    이 명령을 통해 mysqlclient가 필요로 하는 mysql_config 유틸리티를 제공합니다.

MariaDB의 경우:

  1. MariaDB 개발 라이브러리와 헤더를 설치합니다. Ubuntu/Debian에서는 다음 명령을 사용할 수 있습니다.

    sudo apt-get install libmariadb-dev

    CentOS/RHEL에서는 다음 명령을 사용합니다.

    sudo yum install mariadb-devel

    이 명령을 통해 mysqlclient가 필요로 하는 mariadb_config 유틸리티를 제공합니다.

필요한 개발 패키지를 설치한 후, pip를 사용하여 mysqlclient를 다시 설치해 보세요.

pip install mysqlclient==2.1.1

이제 mysqlclient가 필요한 MySQL 또는 MariaDB 라이브러리를 찾아서 성공적으로 설치되어야 합니다.

(venv) root@cfpp020:/home/cfdc010# pip install mysqlclient==2.1.1
Collecting mysqlclient==2.1.1
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/cfdc010/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hd90e9ic/mysqlclient/setup.py'"'"'; file='"'"'/tmp/pip-install-hd90e9ic/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-5r0rdjja
cwd: /tmp/pip-install-hd90e9ic/mysqlclient/
Complete output (22 lines):
mysql_config --version
/bin/sh: 1: mysql_config: not found
mariadb_config --version
['10.6.15']
mariadb_config --libs
['-L/usr/lib/x86_64-linux-gnu/', '-lmariadb']
mariadb_config --cflags
['-I/usr/include/mariadb', '-I/usr/include/mariadb/mysql']
ext_options:
library_dirs: ['/usr/lib/x86_64-linux-gnu/']
libraries: ['mariadb']
extra_compile_args: ['-std=c99']
extra_link_args: []
include_dirs: ['/usr/include/mariadb', '/usr/include/mariadb/mysql']
extra_objects: []
define_macros: [('version_info', "(2,1,1,'final',0)"), ('version', '2.1.1')]
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: invalid command 'bdist_wheel'

ERROR: Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /home/cfdc010/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hd90e9ic/mysqlclient/setup.py'"'"'; file='"'"'/tmp/pip-install-hd90e9ic/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-r85bjdx9/install-record.txt --single-version-externally-managed --compile --install-headers /home/cfdc010/venv/include/site/python3.8/mysqlclient
cwd: /tmp/pip-install-hd90e9ic/mysqlclient/
Complete output (46 lines):
mysql_config --version
/bin/sh: 1: mysql_config: not found
mariadb_config --version
['10.6.15']
mariadb_config --libs
['-L/usr/lib/x86_64-linux-gnu/', '-lmariadb']
mariadb_config --cflags
['-I/usr/include/mariadb', '-I/usr/include/mariadb/mysql']
ext_options:
library_dirs: ['/usr/lib/x86_64-linux-gnu/']
libraries: ['mariadb']
extra_compile_args: ['-std=c99']
extra_link_args: []
include_dirs: ['/usr/include/mariadb', '/usr/include/mariadb/mysql']
extra_objects: []
define_macros: [('version_info', "(2,1,1,'final',0)"), ('version', '2.1.1')]
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/init.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
creating build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/_init
.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
running build_ext
building 'MySQLdb.mysql' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/MySQLdb
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(2,1,1,'final',0) -D__version_
=2.1.1 -I/usr/include/mariadb -I/usr/include/mariadb/mysql -I/home/cfdc010/venv/include -I/usr/include/python3.8 -c MySQLdb/mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/mysql.o -std=c99
MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory
46 | #include "Python.h"
| ^~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/cfdc010/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hd90e9ic/mysqlclient/setup.py'"'"'; __file
='"'"'/tmp/pip-install-hd90e9ic/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-r85bjdx9/install-record.txt --single-version-externally-managed --compile --install-headers /home/cfdc010/venv/include/site/python3.8/mysqlclient Check the logs for full command output.

에러 메시지에 따르면 mysqlclient를 설치하려고 할 때 mysql_configmariadb_config를 찾을 수 없다는 문제가 발생하고 있습니다. 또한 Python.h 헤더 파일을 찾을 수 없다는 추가적인 오류가 있습니다.

이 문제를 해결하려면 다음 단계를 따르세요:

  1. MySQL 또는 MariaDB 개발 라이브러리 설치:

    • Ubuntu/Debian에서 MySQL 개발 라이브러리 및 헤더를 설치하려면 다음 명령을 실행하세요:

      sudo apt-get install libmysqlclient-dev
    • CentOS/RHEL에서 MySQL 개발 라이브러리를 설치하려면 다음 명령을 사용하세요:

      sudo yum install mysql-devel
    • MariaDB를 사용하는 경우, 위의 대신 libmariadb-dev 또는 mariadb-devel 패키지를 설치하세요.

  2. Python 개발 헤더 설치:

    Python.h 헤더 파일을 설치해야 합니다. Ubuntu/Debian에서는 다음 명령으로 설치할 수 있습니다:

    sudo apt-get install python3-dev

    CentOS/RHEL에서는 다음 명령을 사용하세요:

    sudo yum install python3-devel
  3. 가상 환경 활성화:

    가상 환경을 다시 활성화하세요.

    source /home/cfdc010/venv/bin/activate
  4. mysqlclient 다시 설치:

    이제 mysqlclient를 다시 설치해 보세요.

    pip install mysqlclient==2.1.1

이러한 단계를 따르면 mysqlclient가 필요한 라이브러리와 헤더를 찾아서 올바르게 설치될 것입니다.

'python' 카테고리의 다른 글

def copy(self) -> dict: 에서 -> dict: 뜻은  (0) 2025.03.03
실행 EXE 만들기  (0) 2024.10.25
python 상속에서 methed 정의만 사용  (0) 2023.09.15
파이썬에서 @setter 사용법  (0) 2023.09.15
pyqt6에서 폼간 데이터 전송방법  (0) 2023.07.25