Reputation: 33
pip3 install mysqlclient
shows the following error,
Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup_posix.py", line 54, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup_posix.py", line 54, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup_posix.py", line 12, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/
followed some posts and installed
brew install mysql-connector-c
But Still facing the issue.
For other solution tried the following solution,
https://stackoverflow.com/a/44338332/4107739
but couldn't find /usr/local/bin/mysql/bin/mysql_config
I'm running on MacOS, for Mysql I have XAMPP installed.
Upvotes: 3
Views: 1646
Reputation: 1338
For python3 + mysql on mac. This worked for me:
brew install mysql-connector-c
which mysql_config
)Change the following in mysql_config:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
To:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew info openssl
and finally pip3 install mysqlclient
Upvotes: 4
Reputation: 5887
in XAMPP, the mysql_config would be somewhere in the below path. (based where you installed)
/Applications/XAMPP/xamppfiles/bin/mysql_config
Update the $PATH to include bin path
export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin/
Run mysql_config, --libs
and --libs_r
should have -lmysqlclient -lssl -lcrypto
,
<XAMPP_PATH>mysql_config | grep libs
--libs [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto]
--libmysqld-libs [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqld -lssl -lcrypto]
if not, update the mysql_config to following values.
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
then run
pip3 install mysqlclient
Upvotes: 1