0
votes

Im trying to install mysqlclient using pip (python v3.7) to connect mysqldb running in docker and iam getting below error when running pip install mysqlclient, below 2 are installed already brew install mysql (although not needed the mysql_config seems to come with mysql package) brew install mysql-client which mysql_config gives path to mysql_config

    ....
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.macosx-10.9-x86_64-3.7
    creating build/temp.macosx-10.9-x86_64-3.7/MySQLdb
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/local/opt/mysql-client/include -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/local/Cellar/mysql/8.0.19/include/mysql -I/Users/urgensherpa/PycharmProjects/track/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o
    gcc -bundle -undefined dynamic_lookup -arch x86_64 -g -L/usr/local/opt/mysql-client/lib -I/usr/local/opt/mysql-client/include build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/8.0.19/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.cpython-37m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/macuser/PycharmProjects/track/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/vl/vl829c_j3z52_rs99gl693mr0000gn/T/pip-install-lapvpshr/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 /private/var/folders/vl/vl829c_j3z52_rs99gl693mr0000gn/T/pip-record-4mi2bs7_/install-record.txt --single-version-externally-managed --compile --install-headers /Users/macuser/PycharmProjects/track/venv/include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/vl/vl829c_j3z52_rs99gl693mr0000gn/T/pip-install-lapvpshr/mysqlclient/```
1

1 Answers

0
votes

Got the working answer here

echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

pip3 install mysqlclient