mac에서 pip를 통해서 install 시 compile error 가 발생하는 경우가 있습니다.
저의 경우 mysqlclient 설치시 오류가 발생했는데요.
$pip install -U mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.9.tar.gz
Installing collected packages: mysqlclient
Found existing installation: mysqlclient 1.3.7
Uninstalling mysqlclient-1.3.7:
Successfully uninstalled mysqlclient-1.3.7
Running setup.py install for mysqlclient ... error
Complete output from command /Volumes/Macintosh HD/virtualenv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/z5/g5z8xyp94191_q7dyz_j_z440000gn/T/pip-build-yHUcbd/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 /var/folders/z5/g5z8xyp94191_q7dyz_j_z440000gn/T/pip-tPZKUE-record/install-record.txt --single-version-externally-managed --compile --install-headers /Volumes/Macintosh HD/virtualenv/include/site/python2.7/mysqlclient: running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-intel-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.12-intel-2.7
creating build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb
creating build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.12-intel-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.12-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Dversion_info=(1,3,9,'final',1) -D__version__=1.3.9 -I/usr/local/Cellar/mariadb/10.1.18/include/mysql -I/usr/local/Cellar/mariadb/10.1.18/include/mysql/.. -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.12-intel-2.7/_mysql.o
In file included from _mysql.c:40:
In file included from /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8:
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:1062:9: warning: 'SIZEOF_TIME_T' macro redefined [-Wmacro-redefined]
#define SIZEOF_TIME_T 4
^
/usr/local/Cellar/mariadb/10.1.18/include/mysql/my_config.h:660:9: note: previous definition is here
#define SIZEOF_TIME_T 8
^
1 warning generated.
_mysql.c:260:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
cmd_argc = PySequence_Size(cmd_args);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:290:12: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
groupc = PySequence_Size(groups);
~ ^~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:441:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
int j, n2=PySequence_Size(fun);
~~ ^~~~~~~~~~~~~~~~~~~~
_mysql.c:1070:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = mysql_real_escape_string(&(self->connection), out, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1073:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = mysql_escape_string(out, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1116:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
size = PyBytes_GET_SIZE(s);
~ ^~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/bytesobject.h:8:26: note: expanded from macro 'PyBytes_GET_SIZE'
#define PyBytes_GET_SIZE PyString_GET_SIZE
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note: expanded from macro 'PyString_GET_SIZE'
#define PyString_GET_SIZE(op) Py_SIZE(op)
^~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note: expanded from macro 'Py_SIZE'
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
_mysql.c:1128:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = mysql_real_escape_string(&(self->connection), out+1, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1131:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = mysql_escape_string(out+1, in, size);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_mysql.c:1221:11: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
if ((n = PyObject_Length(o)) == -1) goto error;
~ ^~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:434:25: note: expanded from macro 'PyObject_Length'
#define PyObject_Length PyObject_Size
^
_mysql.c:1433:10: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1435:10: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1471:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
len = strlen(buf);
~ ^~~~~~~~~~~
_mysql.c:1473: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 -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mariadb/10.1.18/lib -lmysqlclient -lz -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
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
----------------------------------------
Rolling back uninstall of mysqlclient
Command "/Volumes/Macintosh HD/virtualenv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/z5/g5z8xyp94191_q7dyz_j_z440000gn/T/pip-build-yHUcbd/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 /var/folders/z5/g5z8xyp94191_q7dyz_j_z440000gn/T/pip-tPZKUE-record/install-record.txt --single-version-externally-managed --compile --install-headers /Volumes/Macintosh HD/virtualenv/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/z5/g5z8xyp94191_q7dyz_j_z440000gn/T/pip-build-yHUcbd/mysqlclient/
오류의 원인은 compile에 필요한 xcode-select 가 설치되어 있지 않아서입니다.
아래와 같이 xcode-select를 설치해 주면 문제없이 pip로 설치 가능해집니다.
$ xcode-select --install
$ pip install -U phonenumbers
/home/deploy/sites/event.kidsnote.com/virtualenv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/home/deploy/sites/event.kidsnote.com/virtualenv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting phonenumbers
Downloading phonenumbers-7.7.3-py2.py3-none-any.whl (2.7MB)
100% |████████████████████████████████| 2.7MB 280kB/s
Installing collected packages: phonenumbers
Found existing installation: phonenumbers 7.2.4
Uninstalling phonenumbers-7.2.4:
Successfully uninstalled phonenumbers-7.2.4
Successfully installed phonenumbers-7.7.3