📌 이 포스팅에서는 가상환경에 mysqlclient 설치 시 발생한 에러 해결 과정에 대해 정리하였습니다.
✔️ 아래 끝없는 에러.....
✔️ xcrun: error: invalid active developer path와 command 'gcc' failed with exit status 1 에러가 났다.
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/jangjaewon/miniconda3/envs/study/include -arch x86_64 -I/Users/jangjaewon/miniconda3/envs/study/include -arch x86_64 -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/usr/local/Cellar/mysql/8.0.27/include/mysql -I/Users/jangjaewon/miniconda3/envs/study/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.8/MySQLdb/_mysql.o -std=c99 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: command 'gcc' failed with exit status 1 ---------------------------------------- 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: /Users/jangjaewon/miniconda3/envs/study/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-install-kwsrgvfa/mysqlclient_f25d6a817c094c70b6f560a40da385af/setup.py'"'"'; __file__='"'"'/private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-install-kwsrgvfa/mysqlclient_f25d6a817c094c70b6f560a40da385af/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-record-q47ilifo/install-record.txt --single-version-externally-managed --compile --install-headers /Users/jangjaewon/miniconda3/envs/study/include/python3.8/mysqlclient cwd: /private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-install-kwsrgvfa/mysqlclient_f25d6a817c094c70b6f560a40da385af/ Complete output (41 lines): mysql_config --version ['8.0.27'] mysql_config --libs ['-L/usr/local/Cellar/mysql/8.0.27/lib', '-lmysqlclient', '-lz', '-lzstd', '-lssl', '-lcrypto', '-lresolv'] mysql_config --cflags ['-I/usr/local/Cellar/mysql/8.0.27/include/mysql'] ext_options: library_dirs: ['/usr/local/Cellar/mysql/8.0.27/lib'] libraries: ['mysqlclient', 'resolv'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/usr/local/Cellar/mysql/8.0.27/include/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')] running install running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.8 creating build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb creating build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.9-x86_64-3.8 creating build/temp.macosx-10.9-x86_64-3.8/MySQLdb gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/jangjaewon/miniconda3/envs/study/include -arch x86_64 -I/Users/jangjaewon/miniconda3/envs/study/include -arch x86_64 -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/usr/local/Cellar/mysql/8.0.27/include/mysql -I/Users/jangjaewon/miniconda3/envs/study/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.8/MySQLdb/_mysql.o -std=c99 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /Users/jangjaewon/miniconda3/envs/study/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-install-kwsrgvfa/mysqlclient_f25d6a817c094c70b6f560a40da385af/setup.py'"'"'; __file__='"'"'/private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-install-kwsrgvfa/mysqlclient_f25d6a817c094c70b6f560a40da385af/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/h7/yslrnv3s17n63c0cm9tmd4j40000gn/T/pip-record-q47ilifo/install-record.txt --single-version-externally-managed --compile --install-headers /Users/jangjaewon/miniconda3/envs/study/include/python3.8/mysqlclient Check the logs for full command output.
✔️ 아래 에러코드가 핵심인것 같아. xcrun error에 대해서 검색해 보았다.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: command 'gcc' failed with exit status 1
✔️ mac os 업데이트를 한 후 발생하는 Error 이라 한다.
✔️ 아래 코드를 실행시킨다. 시간이 좀 걸린다.
>$ xcode-select --install
✔️ 혹시 이미 설치가 되어있고 경로가 꼬여있을때는 아래 명령어를 입력하자.
>$ xcode-select --reset
✔️ 너무 잘된다. 휴.