티스토리 뷰
저는 Openstack 관련 개발을 주로 하고 있는데, Mac OS를 새로 설치하고 나서 개발 환경 세팅할 때마다 MySQL-python을 pip를 활용하여 설치할 때마다 오류가 나곤 했다.
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
<pip install MySQL-python==1.2.5에 대한 오류>
개발에 치우쳐 그때 그 때 해결하고 정리를 해두지 않으니 매 번 해결 방법을 찾아서 뒤지고, 실패하고 하....
해서 이 번엔 이를 꼭 정리해서 다음에 내가 보려고 이를 정리합니다. 혹, 같은 고민에 빠지신 분들에게도 도움이 되길 바래 봅니다.
System environment
CPU : 3.1 GHz Dual Core Intel Core i5
RAM : 16GB 2133 Mhz LPDDR3
Graphic : Intel Iris Plus Graphics 650 1536 MB
OS : macOS Big Sur 11.0.1
Python : Python 2.7.X
우선 설치에 앞서 반드시 homebrew를 설치할 것을 추천한다. 아래 명령어를 터미널에 입력하여 homebrew를 설치합니다.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew에서 mysql 관련 내용을 검색하면 아래 그림과 같은 내역들이 나오는데, 이 것들을 아무리 이렇게 설치하고 저렇게 설치해도 에러는 계속된다.
해서 우선 brew를 통하여 설치되어 있는 전체 mysql관련 내역들을 삭제하고 mysql만 설치하도록 한다.
$ brew uninstall /mysql/ && brew install mysql
그러고 나서 mysql 관련 심볼릭 링크에 대해서 확실히 해둔다.
$ brew link mysql
이렇게 하고 나면 my_config 헤더 파일을 다운로드한다.
$ cd ~/Downloads
Downloads $ curl https://raw.githubusercontent.com/jacobjohn2016/MySQL-Medium/main/my_config.h -o my_config.h
다운로드한 my_config.h파일은 mysql 폴더에 옮겨 준다.
$ mysql --version
mysql Ver 8.0.22 for osx10.16 on x86_64 (Homebrew)
$ cd /usr/local/Cellar/mysql/8.0.22_1/include/mysql
mysql $ ls -al
total 736
drwxr-xr-x 17 rnd1 staff 544 12 10 16:51 .
drwxr-xr-x 3 rnd1 staff 96 9 23 22:05 ..
-rw-r--r-- 1 rnd1 staff 5573 9 23 22:05 errmsg.h
-rw-r--r-- 1 rnd1 staff 3169 9 23 22:05 field_types.h
-rw-r--r-- 1 rnd1 staff 4386 9 23 22:05 my_command.h
-rw-r--r-- 1 rnd1 staff 3661 9 23 22:05 my_compress.h
-rw-r--r-- 1 rnd1 staff 2186 9 23 22:05 my_list.h
drwxr-xr-x 5 rnd1 staff 160 9 23 22:05 mysql
-rw-r--r-- 1 rnd1 staff 32818 9 23 22:05 mysql.h
-rw-r--r-- 1 rnd1 staff 35020 9 23 22:05 mysql_com.h
-rw-r--r-- 1 rnd1 staff 3575 9 23 22:05 mysql_time.h
-rw-r--r-- 1 rnd1 staff 1056 9 23 22:05 mysql_version.h
-rw-r--r-- 1 rnd1 staff 230498 9 23 22:05 mysqld_error.h
-rw-r--r-- 1 rnd1 staff 7226 9 23 22:05 mysqlx_ername.h
-rw-r--r-- 1 rnd1 staff 4133 9 23 22:05 mysqlx_error.h
-rw-r--r-- 1 rnd1 staff 1817 9 23 22:05 mysqlx_version.h
$ cp ~/Downlaods/my_config.h ./
이렇게 하고 나면 이제 pip를 통하여 MySQL-python을 설치하는데 에러 없이 설치가 될 것이다.
$ cd ~/workspace/git/gitproject
gitproject $ source ./venv/bin/activate
(venv) $ pip install MySQL-python==1.2.5
참고 자료 출처 Medium 'Fixing "my_config.h" file not found in MySQL-python (Mac OS)'
P.S brew install mysql 버전이 8.0.22 이후 버전의 경우 아래의 오류가 계속된다면 export 선언으로 해결할 수 있습니다.
_mysql.c:1504:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1506:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
13 warnings generated.
cc -bundle -undefined dynamic_lookup -Wl,-F. -L/System/Volumes/Data/SWE/macOS/BuildRoots/e90674e518/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.Internal.sdk/usr/local/libressl/lib build/temp.macosx-11.4-x86_64-2.7/_mysql.o -L/usr/local/Cellar/mysql/8.0.25_1/lib -lmysqlclient -lz -lzstd -lssl -lcrypto -lresolv -o build/lib.macosx-11.4-x86_64-2.7/_mysql.so
ld: warning: directory not found for option '-L/System/Volumes/Data/SWE/macOS/BuildRoots/e90674e518/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.4.Internal.sdk/usr/local/libressl/lib'
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/rnd2/workspace/git/openstackit-queens/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/dj/lynlxv8n67vfr8nh9hp216s40000gn/T/pip-install-E7X2El/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/dj/lynlxv8n67vfr8nh9hp216s40000gn/T/pip-install-E7X2El/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/dj/lynlxv8n67vfr8nh9hp216s40000gn/T/pip-record-IzEFV5/install-record.txt --single-version-externally-managed --compile --install-headers /Users/rnd2/workspace/git/openstackit-queens/venv/include/site/python2.7/MySQL-python Check the logs for full command output.
아래 LDFLAGS를 export 선언 합니다.
export LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
후에 pip install MySQL-python==1.2.5 설치한다면 오류없이 설치가 가능합니다.
'Develop Story' 카테고리의 다른 글
HA Proxy - Apache Jakarta - Apache Tomcat 구성에서 Tomcat에 실제 Client IP 확인하기(X-Forwarded-For) (3) | 2014.04.22 |
---|---|
Apache Cordova 크로스 플랫폼 HTML5 어플리케이션 만들기-4장 (0) | 2012.10.04 |
Apache Cordova 크로스 플랫폼 HTML5 어플리케이션 만들기-3장 (0) | 2012.09.20 |
객체지향프로그램에 있어 중요한 나만의 고찰 - 세포단위 기능구현 (0) | 2012.09.18 |
Spring + mybatis 환경에서 xml 파일 변경시 서버 재시작 없이 반영 방법 (0) | 2012.08.22 |
- Total
- Today
- Yesterday
- /etc/sysconfig/i18n
- /usr/lib/jni
- 1.3
- 1.5.1
- 1.8.x
- 12.04
- 12.10
- 13
- 3.0
- 3G
- 3월
- 4.0
- 4.0+
- 4.X
- 4G
- 5
- 64
- 64bit
- 777
- admin
- Adobe
- adobe air
- Adobeair
- Air
- ajax
- AJP
- Altool
- Altool bar
- AMD64
- Andoird
- Andrew's Eggtart
- Andrew's Eggtart & Coffee
- android
- Angel in Us
- Apache
- Apache + PHP 설치
- Apache + PHP 수동 설치
- Apache + PHP 수동 세팅
- API
- APIS
- APM 설치
- APM설치
- apple
- Application
- apps
- apt-get
- apt-get --purge
- Band of Dynamic Brothers
- Beta
- Big sur
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |