mysqlclient 오류 메시지
root@2230da7c6145:/code/backend# pip install mysqlclient
Collecting mysqlclient
Downloading mysqlclient-2.2.1.tar.gz (89 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.0/90.0 kB 4.1 MB/s eta 0:00:00
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
/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.
Trying pkg-config --exists libmariadb
Command 'pkg-config --exists libmariadb' returned non-zero exit status 127.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-x98cru2x/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-x98cru2x/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-x98cru2x/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 155, 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
[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.
Exception: Can not find valid pkg-config name.
note: This error originates from a subprocess, and is likely not a problem with pip.
주요 오류 포인트는 위와 같다.
이를 해결 하기 위해 필요 내용 설치가 진행되어야 하다.
해결 방법
sudo apt update
먼저, update부터 해준다.
sudo apt install default-libmysqlclient-dev pkg-config -y
apt install을 통해 해당 내용 설치. 나는 가상 환경에서 python을 구동중이기에 sudo 없이 입력하였다.
pip install mysqlclient
다음, 오류를 냈던 패키지를 다시 설치한다.
정상 설치가 이루어지면 끝.
하지만, 매끄럽게 진행되지 않고 또 다른 오류가 나타났다.
reference
https://www.sysnet.pe.kr/2/0/13377
gcc 오류 메시지
root@79af3100fec0:/code# pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.2.1.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for mysqlclient (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [41 lines of output]
Trying pkg-config --exists mysqlclient
# Options for building extension module:
extra_compile_args: ['-I/usr/include/mariadb/', '-std=c99']
extra_link_args: ['-L/usr/lib/x86_64-linux-gnu/', '-lmariadb']
define_macros: [('version_info', (2, 2, 1, 'final', 0)), ('__version__', '2.2.1')]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-310
creating build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
copying src/MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants
copying src/MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
copying src/MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
copying src/MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
copying src/MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
copying src/MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
running egg_info
writing src/mysqlclient.egg-info/PKG-INFO
writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt
writing top-level names to src/mysqlclient.egg-info/top_level.txt
reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-310/MySQLdb
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-cpython-310
creating build/temp.linux-x86_64-cpython-310/src
creating build/temp.linux-x86_64-cpython-310/src/MySQLdb
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC "-Dversion_info=(2, 2, 1, 'final', 0)" -D__version__=2.2.1 -I/usr/local/include/python3.10 -c src/MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/src/MySQLdb/_mysql.o -I/usr/include/mariadb/ -std=c99
error: command 'gcc' failed: No such file or directory
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mysqlclient
Failed to build mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
error: command 'gcc' failed: No such file or directory
sudo apt-get -y install gcc
gcc 를 인스톨한다.
pip install mysqlclient
다시, mysqlclient를 인스톨한다.
root@79af3100fec0:/code# pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.2.1.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (pyproject.toml) ... done
Created wheel for mysqlclient: filename=mysqlclient-2.2.1-cp310-cp310-linux_x86_64.whl size=131954 sha256=51449f8065f580713e62b626442f90b9772632f48adeccccc803101b9cce017f
Stored in directory: /root/.cache/pip/wheels/93/84/49/615c5604001ebe3bb11c45628f22102cf563d6766a43a0e7a1
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
이제서야 설치 성공 메시지를 볼 수 있었다.
나의 경우 이렇게 진행하여 해결하였다.
'알아가기 > Python' 카테고리의 다른 글
[Python] 교집합, 합집합, 차집합, 대칭 차집합 (0) | 2023.01.05 |
---|---|
[Python] 리스트 안의 문자 붙여서 출력 (0) | 2022.12.31 |
[Python] 0 1 반전 방법 (0) | 2022.12.21 |
[Python] __name__ 을 프린트 해보자 (0) | 2022.10.10 |