web-dev-qa-db-ja.com

pip install mysqlclientが失敗しました「mysqlclientのsetup.py bdist_wheelの実行...エラー」

最初にpipenv installを実行して依存関係を取得することにより、新しくフォーマットされたMac OS High Sierra 10.13.4でPython 3プロジェクトを実行しようとしていますが、失敗します。

具体的には、依存関係のインストールに失敗する部分はmysqlclient部分です。

このエラーメッセージは現れます:

_mysql.c:1894:3: error: use of undeclared identifier 'my_bool'
              my_bool recon = reconnect;
              ^
_mysql.c:1895:58: error: use of undeclared identifier 'recon'
              mysql_options(&self->connection, MYSQL_OPT_RECONNECT, &recon);
                                                                     ^

構成

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> python --version
Python 2.7.10

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> python3 --version
Python 3.6.5

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> brew install mysql-connector-c
Warning: mysql-connector-c 6.1.11 is already installed, its just not linked
You can use `brew link mysql-connector-c` to link this version.

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> brew link mysql-connector-c
Linking /usr/local/Cellar/mysql-connector-c/6.1.11... 
Error: Could not symlink bin/my_print_defaults
Target /usr/local/bin/my_print_defaults
is a symlink belonging to mysql. You can unlink it:
  brew unlink mysql

To force the link and overwrite all conflicting files:
  brew link --overwrite mysql-connector-c

To list all files that would be deleted:
  brew link --overwrite --dry-run mysql-connector-c

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> mysql --version
mysql  Ver 8.0.11 for macos10.13 on x86_64 (MySQL Community Server - GPL)

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> brew install mysql
Warning: mysql 5.7.22 is already installed and up-to-date
To reinstall 5.7.22, run `brew reinstall mysql`

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> brew info openssl
openssl: stable 1.0.2o (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2o_1 (1,791 files, 12.3MB)
  Poured from bottle on 2018-04-20 at 13:06:42
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
==> Dependencies
Build: makedepend ✘
==> Options
--without-test
    Skip build-time tests (not recommended)
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

完全な端末エラーログ

darrenkarlsapalo@admins-MacBook-Pro ~/g/t/thesis-nltk> pip install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient ... error
  Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-install-mj5god72/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-wheel-_frnx3t4 --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.6
  copying _mysql_exceptions.py -> build/lib.macosx-10.9-x86_64-3.6
  creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
  creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.9-x86_64-3.6
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Arch x86_64 -g -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.9-x86_64-3.6/_mysql.o
  _mysql.c:1894:3: error: use of undeclared identifier 'my_bool'
                  my_bool recon = reconnect;
                  ^
  _mysql.c:1895:58: error: use of undeclared identifier 'recon'
                  mysql_options(&self->connection, MYSQL_OPT_RECONNECT, &recon);
                                                                         ^
  2 errors generated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-install-mj5god72/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/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-record-vkhrazcr/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.6
    copying _mysql_exceptions.py -> build/lib.macosx-10.9-x86_64-3.6
    creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
    creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.9-x86_64-3.6
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Arch x86_64 -g -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.9-x86_64-3.6/_mysql.o
    _mysql.c:1894:3: error: use of undeclared identifier 'my_bool'
                    my_bool recon = reconnect;
                    ^
    _mysql.c:1895:58: error: use of undeclared identifier 'recon'
                    mysql_options(&self->connection, MYSQL_OPT_RECONNECT, &recon);
                                                                           ^
    2 errors generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-install-mj5god72/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/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-record-vkhrazcr/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/75/hg3nj2sx13567pbv76wdycqm0000gn/T/pip-install-mj5god72/mysqlclient/

pythonのすべてのインストールをアンインストールしたいという欲求不満ですが、Macでビルド済みの古いPythonバージョンに依存する何かを台無しにするのではないかと心配しています。

依存関係を正しくインストールするにはどうすればよいですか?

14
iwillnot

mysqlclient は、この記事の執筆時点ではMySQL 8.0.11と互換性がありません。 MySQL v5.7.xを使用すると、この問題が修正されます(少なくともmacOSでは)。

20
fiveclubs

このエラーが発生する場合:

収集されたパッケージのホイールの構築:mysqlclient mysqlclientのsetup.py bdist_wheelの実行...エラー

Pipを使用してmyclientをインストールした後、次の手順に従います。

  1. Miniconodaのダウンロード(サイズが小さく、必要なファイルが含まれています)/ anacondoa(all) クリックしてMinicondaをダウンロード

  2. インストールする

  3. Cmdのcommind "conda list"を使用してインストールを確認します

  4. 次に、このコマンドを実行します。「conda install -c miniconda mysqlclient」これは、mysqlclientをインストールする代替方法です。

正常に実行された後、再度pip install mysqlclientを実行すると、sqlclientがすでに正常にインストールされていることがわかります。

これで問題が解決することを願っています。それでもエラーの詳細を共有しないでください。助けてみたい。

0
Damodar Singh