문제 상황
macos에서 django 서버를 실행하려고 mysqlclient를 설치하는데, 설치가 안된다.. 오류 메시지는 아래와 같다.
Requirement already satisfied: pip in [로컬경로]/.pyenv/versions/3.10.6/envs/airecom/lib/python3.10/site-packages (22.2.1)
Collecting pip
Downloading pip-22.3.1-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 3.5 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.2.1
Uninstalling pip-22.2.1:
Successfully uninstalled pip-22.2.1
Successfully installed pip-22.3.1
(base) (airecom) ➜ airecomsite git:(main) ✗ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/3w/d2tbzl514t11x77xrmm6v44c0000gn/T/pip-install-333v9jo4/mysqlclient_b7d126da062f472ea0fb9bfa381e00d5/setup.py", line 15, in <module>
metadata, options = get_config()
File "/private/var/folders/3w/d2tbzl514t11x77xrmm6v44c0000gn/T/pip-install-333v9jo4/mysqlclient_b7d126da062f472ea0fb9bfa381e00d5/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/private/var/folders/3w/d2tbzl514t11x77xrmm6v44c0000gn/T/pip-install-333v9jo4/mysqlclient_b7d126da062f472ea0fb9bfa381e00d5/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
[end of output]
해결 방안
다음을 통해 mysql을 설치한다. PyPl/mysqlclient 참고
brew install mysql
위처럼 mysql을 설치하고 나면, 아래와 같이 pip를 통한 mysqlclient 설치가 가능해진다.
$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... done
Created wheel for mysqlclient: filename=mysqlclient-2.1.1-cp310-cp310-macosx_12_0_x86_64.whl size=56347 sha256=7a2b6c4527fa7d95f57db53a8216b61b3b5bd099c19a1893c2483a8b3315c8e8
Stored in directory: [로컬경로]/Library/Caches/pip/wheels/8a/d4/6c/8193c9bc0aa8da0172e4f59ec5600a751eb707263971da8213
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.1.1
참고:
mysql을 설치하였다고 해서 바로 실행되는 것이 아니며, 다음과 같이 실행할 수 있음
#실행
$ mysql.server start
# 데몬으로 실행
$ brew services start mysql
# 재시작
$ brew services restart mysql
# 실행 중인 프로세스 확인
$ brew services list
# 종료
$ mysql.server stop
# 데몬 프로세스 종료
$ brew services stop mysql
반응형
'CS > 삽질로그' 카테고리의 다른 글
[MLOps] kubeadm으로 클러스터 구축 시 권한 오류 (0) | 2022.11.29 |
---|---|
[python] django 모델 변경 시 에러 발생 (0) | 2022.11.24 |
[docker, opencv] docker opencv 에러 (libGL.so.1: cannot open shared object file) (0) | 2022.11.09 |
[python] logging 라이브러리 오류 (0) | 2022.10.28 |
[kubeflow, kubernetes] 에러 파드 삭제하는 방법 (kubeflow delete error pod) (0) | 2022.10.28 |