Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot pip3 install mysqlclient

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.

like image 458
Sundareswaran Avatar asked Jul 13 '26 12:07

Sundareswaran


1 Answers

For python3 + mysql on mac. This worked for me:

  1. brew install mysql-connector-c
  2. edit mysql_config (locate it: 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"
  1. brew info openssl

  2. and finally pip3 install mysqlclient

like image 81
IJR Avatar answered Jul 16 '26 04:07

IJR