windows 7环境
1.进入命令行执行以下命令:
C:\Users\Administrator>pip install mysql-connector
注:安装下载较慢,直接失败,改用VPN安装速度加快,但下载完成后安装报错。
Collecting mysql-connector
Using cached mysql-connector-2.2.3.zip
Installing collected packages: mysql-connector
Running setup.py install for mysql-connector ... error
Complete output from command "c:\program files\python36\python.exe" -u -c "i
mport setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\
pip-build-4wy1t6ee\\mysql-connector\\setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __fi
le__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-4ft9q_
7k-record\install-record.txt --single-version-externally-managed --compile:
running install
Not Installing MySQL C Extension
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\mysql
copying lib\mysql\__init__.py -> build\lib.win-amd64-3.6\mysql
creating build\lib.win-amd64-3.6\mysql\connector
copying lib\mysql\connector\abstracts.py -> build\lib.win-amd64-3.6\mysql\co
nnector
copying lib\mysql\connector\authentication.py -> build\lib.win-amd64-3.6\mys
ql\connector
copying lib\mysql\connector\catch23.py -> build\lib.win-amd64-3.6\mysql\conn
ector
copying lib\mysql\connector\charsets.py -> build\lib.win-amd64-3.6\mysql\con
nector
copying lib\mysql\connector\connection.py -> build\lib.win-amd64-3.6\mysql\c
onnector
copying lib\mysql\connector\connection_cext.py -> build\lib.win-amd64-3.6\my
sql\connector
copying lib\mysql\connector\constants.py -> build\lib.win-amd64-3.6\mysql\co
nnector
copying lib\mysql\connector\conversion.py -> build\lib.win-amd64-3.6\mysql\c
onnector
copying lib\mysql\connector\cursor.py -> build\lib.win-amd64-3.6\mysql\conne
ctor
copying lib\mysql\connector\cursor_cext.py -> build\lib.win-amd64-3.6\mysql\
connector
copying lib\mysql\connector\custom_types.py -> build\lib.win-amd64-3.6\mysql
\connector
copying lib\mysql\connector\dbapi.py -> build\lib.win-amd64-3.6\mysql\connec
tor
copying lib\mysql\connector\errorcode.py -> build\lib.win-amd64-3.6\mysql\co
nnector
copying lib\mysql\connector\errors.py -> build\lib.win-amd64-3.6\mysql\conne
ctor
copying lib\mysql\connector\network.py -> build\lib.win-amd64-3.6\mysql\conn
ector
copying lib\mysql\connector\optionfiles.py -> build\lib.win-amd64-3.6\mysql\
connector
copying lib\mysql\connector\pooling.py -> build\lib.win-amd64-3.6\mysql\conn
ector
copying lib\mysql\connector\protocol.py -> build\lib.win-amd64-3.6\mysql\con
nector
copying lib\mysql\connector\utils.py -> build\lib.win-amd64-3.6\mysql\connec
tor
copying lib\mysql\connector\version.py -> build\lib.win-amd64-3.6\mysql\conn
ector
copying lib\mysql\connector\__init__.py -> build\lib.win-amd64-3.6\mysql\con
nector
creating build\lib.win-amd64-3.6\mysql\connector\locales
copying lib\mysql\connector\locales\__init__.py -> build\lib.win-amd64-3.6\m
ysql\connector\locales
creating build\lib.win-amd64-3.6\mysql\connector\locales\eng
copying lib\mysql\connector\locales\eng\client_error.py -> build\lib.win-amd
64-3.6\mysql\connector\locales\eng
copying lib\mysql\connector\locales\eng\__init__.py -> build\lib.win-amd64-3
.6\mysql\connector\locales\eng
creating build\lib.win-amd64-3.6\mysql\connector\django
copying lib\mysql\connector\django\base.py -> build\lib.win-amd64-3.6\mysql\
connector\django
copying lib\mysql\connector\django\client.py -> build\lib.win-amd64-3.6\mysq
l\connector\django
copying lib\mysql\connector\django\compiler.py -> build\lib.win-amd64-3.6\my
sql\connector\django
copying lib\mysql\connector\django\creation.py -> build\lib.win-amd64-3.6\my
sql\connector\django
copying lib\mysql\connector\django\features.py -> build\lib.win-amd64-3.6\my
sql\connector\django
copying lib\mysql\connector\django\introspection.py -> build\lib.win-amd64-3
.6\mysql\connector\django
copying lib\mysql\connector\django\operations.py -> build\lib.win-amd64-3.6\
mysql\connector\django
copying lib\mysql\connector\django\schema.py -> build\lib.win-amd64-3.6\mysq
l\connector\django
copying lib\mysql\connector\django\validation.py -> build\lib.win-amd64-3.6\
mysql\connector\django
copying lib\mysql\connector\django\__init__.py -> build\lib.win-amd64-3.6\my
sql\connector\django
creating build\lib.win-amd64-3.6\mysql\connector\fabric
copying lib\mysql\connector\fabric\balancing.py -> build\lib.win-amd64-3.6\m
ysql\connector\fabric
copying lib\mysql\connector\fabric\caching.py -> build\lib.win-amd64-3.6\mys
ql\connector\fabric
copying lib\mysql\connector\fabric\connection.py -> build\lib.win-amd64-3.6\
mysql\connector\fabric
copying lib\mysql\connector\fabric\__init__.py -> build\lib.win-amd64-3.6\my
sql\connector\fabric
creating build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\authentication.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\charsets.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\compat.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\connection.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\constants.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\crud.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\dbdoc.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\errorcode.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\errors.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\expr.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\protobuf.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\protocol.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\result.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\statement.py -> build\lib.win-amd64-3.6\mysqlx
copying lib\mysqlx\__init__.py -> build\lib.win-amd64-3.6\mysqlx
creating build\lib.win-amd64-3.6\mysqlx\locales
copying lib\mysqlx\locales\__init__.py -> build\lib.win-amd64-3.6\mysqlx\loc
ales
creating build\lib.win-amd64-3.6\mysqlx\locales\eng
copying lib\mysqlx\locales\eng\client_error.py -> build\lib.win-amd64-3.6\my
sqlx\locales\eng
copying lib\mysqlx\locales\eng\__init__.py -> build\lib.win-amd64-3.6\mysqlx
\locales\eng
running build_ext
# Python architecture: 64-bit
# Python ARCH_64BIT: True
Unable to find Protobuf include directory.
----------------------------------------
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokeni
ze;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-build-4wy1t6ee\\mysq
l-connector\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read()
.replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record C:\Users\ADMINI~1\AppData\Local\Temp\pip-4ft9q_7k-record\install-record
.txt --single-version-externally-managed --compile" failed with error code 1 in
C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-4wy1t6ee\mysql-connector\
2.遂改用旧版本安装
C:\Users\Administrator>pip install mysql-connector==2.1.4 (通过指定旧版本号安装旧版本)
Collecting mysql-connector==2.1.4
Downloading mysql-connector-2.1.4.zip (355kB)
...
B 19kB/s
Installing collected packages: mysql-connector
Running setup.py install for mysql-connector ... done
Successfully installed mysql-connector-2.1.4
3.暂不清楚如何新版本如何安装
参考文档:http://www.cnblogs.com/JiangLe/p/6971134.html