问题描述
我正在使用新的MacOS High Sierra 10.13.5。
我首先使用Homebrew安装了python3:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install python
然后我从github克隆了我的python项目存储库,该存储库有一个requirements.txt文件,其中包含以下行:
mysqlclient==1.3.10
然后,我创建了一个虚拟环境并运行pip安装:
python3 -m venv venv
pip install -r api/requirements.txt
然后出现以下错误:
...
...
Installing collected packages: six, python-dateutil, aniso8601,
appdirs, jmespath, docutils, botocore, s3transfer, boto3, click, Werkzeug, itsdangerous, MarkupSafe, Jinja2, Flask, Flask-Cors, blinker, Flask-Mail, jsonschema, pytz, flask-restplus, Flask-Script, SQLAlchemy, Flask-SQLAlchemy, Flask-SQLAlchemy-Session, Mako, python-editor, alembic, Flask-Migrate, PyJWT, Flask-JWT-Simple, idna, pycparser, cffi, asn1crypto, cryptography, chardet, certifi, urllib3, requests, nexmo, pyparsing, packaging, Pillow, phonenumbers, numpy, timezonefinder, decorator, ratelim, geocoder, SQLAlchemy-Utils, mysqlclient, pycrypto, simple-crypt, suds-jurko, Salesforce-FuelSDK, schedule, python-utils, progressbar2, timeago
Running setup.py install for aniso8601 ... done
Running setup.py install for itsdangerous ... done
Running setup.py install for MarkupSafe ... done
Running setup.py install for blinker ... done
Running setup.py install for Flask-Mail ... done
Running setup.py install for Flask-Script ... done
Running setup.py install for SQLAlchemy ... done
Running setup.py install for Flask-SQLAlchemy-Session ... done
Running setup.py install for Mako ... done
Running setup.py install for python-editor ... done
Running setup.py install for Flask-JWT-Simple ... done
Running setup.py install for pycparser ... done
Running setup.py install for geocoder ... done
Running setup.py install for SQLAlchemy-Utils ... done
Running setup.py install for mysqlclient ... error
Complete output from command /Users/mvi/mvi/server/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-install-vls9kk27/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/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-record-6eq5p42p/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mvi/mvi/server/venv/include/site/python3.7/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.13-x86_64-3.7
copying _mysql_exceptions.py -> build/lib.macosx-10.13-x86_64-3.7
creating build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
creating build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.13-x86_64-3.7
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/mysql/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/Users/mvi/mvi/server/venv/include -I/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c _mysql.c -o build/temp.macosx-10.13-x86_64-3.7/_mysql.o
_mysql.c:29:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/Users/mvi/mvi/server/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-install-vls9kk27/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/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-record-6eq5p42p/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mvi/mvi/server/venv/include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-install-vls9kk27/mysqlclient/
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
在我的旧Macbook Pro上,我没有这个问题。 在那本Macbook上,我有使用GCC 4.2.1的python 3.6.5。 在这台新的Macbook上,我有python 3.7,使用lang 9.1.0(venv)$ python Python 3.7.0(默认,Aug 22 2018,15:22:33)[dar 9.1.0(clang-902.0.39.2)]
本文是我所能想到的惟一一件事,但似乎并没有太大帮助。
任何调试的想法将不胜感激。 谢谢。
1楼
您需要MySQL客户端库及其相关的标头。
这些是在Brew中的MariaDB(MySQL fork)软件包中提供的,因此brew install mariadb
应该可以解决问题。