mysqlclientをインストールしようとするとCommand "python setup.py egg_info" failed with error code 1 iのエラーになる。

Python 3.6の環境を新たに作成しmysqlclientをインストールするために以下のコマンド

-----------------

pip install mysqlclient

-----------------

を実行すると以下のエラーに遭遇しました。

-----------------

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/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/mysqlclient/setup.py", line 17, in <module>

        metadata, options = get_config()

      File "/private/var/folders/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/cmysqlclient/setup_posix.py", line 54, in get_config

        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]

      File "/private/var/folders/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/mysqlclient/setup_posix.py", line 54, in <listcomp>

        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]

      File "/private/var/folders/4u/ggkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/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/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/mysqlclient/

-----------------

このエラーに対して/usr/local/bin/mysql_configを変更し再度コマンドを実行すると成功するようになった。

 

変更前

-----------------

libs="-L$pkglibdir"

libs="$libs -l "

-----------------

 

変更後

-----------------

libs="-L$pkglibdir"

libs="$libs -lmysqlclient -lssl -lcrypto”

-----------------

 

コマンドの再実行

-----------------

$pip install mysqlclient

Collecting mysqlclient

  Using cached mysqlclient-1.3.12.tar.gz

Installing collected packages: mysqlclient

  Running setup.py install for mysqlclient ... done

Successfully installed mysqlclient-1.3.12

-----------------

この変更によりエラーが解消されました。

https://github.com/PyMySQL/mysqlclient-python

 

 

 

When I tried to install mysqlclient, Command error with “ Command python setup.py egg_info" failed with error code 1 i” was shown.

 

A Python3.6 project was created and I tried to install mysqlclient with the following command.

――-

pip install mysqlclient

――-

 

But, I encountered the 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/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/mysqlclient/setup.py", line 17, in <module>

        metadata, options = get_config()

      File "/private/var/folders/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/cmysqlclient/setup_posix.py", line 54, in get_config

        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]

      File "/private/var/folders/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/mysqlclient/setup_posix.py", line 54, in <listcomp>

        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]

      File "/private/var/folders/4u/ggkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/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/4u/gkkn775hhg7_zjzhpjhhgga0000gn/T/pip-build-_1ie9suf/mysqlclient/

――-

 

After that, I reviewed the procedure to implement it at github.

https://github.com/PyMySQL/mysqlclient-python

 

According to the instruction, it is need to revise /usr/local/bin/mysql_config file. Afterward, I tried it again.

 

Before the change:

libs="-L$pkglibdir"

libs="$libs -l "

 

After the change:

libs="-L$pkglibdir"

libs="$libs -lmysqlclient -lssl -lcrypto”

 

Perform the command again:

$pip install mysqlclient

Collecting mysqlclient

  Using cached mysqlclient-1.3.12.tar.gz

Installing collected packages: mysqlclient

  Running setup.py install for mysqlclient ... done

Successfully installed mysqlclient-1.3.12