Jul
06
2017

How to Install mysql-connector for Python

For several months Python mysql-connector has been broken when attempting a install from pip.  In truth I’ve only tried Python 3, CentOS 6/7 and Fedora 21; in fact, this could be a more wide spread.  The simple solution is to install an earlier version.  The purpose of this post is to be a quick reminder of which is the most recent working version!

[root@localhost site-packages]# pip3 install –upgrade pip
Requirement already up-to-date: pip in ./pip-9.0.1-py3.4.egg
[root@localhost site-packages]# pip3 install mysql-connector
Collecting mysql-connector
Downloading mysql-connector-2.2.3.zip (12.1MB)
100% |████████████████████████████████| 12.1MB 96kB/s
Installing collected packages: mysql-connector
Running setup.py install for mysql-connector … error

It ends with this error about missing Protobuf error:

running build_ext
# Python architecture: 64-bit
# Python ARCH_64BIT: True
Unable to find Protobuf include directory.
———————————————-
Command “/bin/python3 -u -c “import setuptools, tokenize;__file__=’/tmp/pip-build-_ggnrdbx/mysql-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 /tmp/pip-sb5fhtjr-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-_ggnrdbx/mysql-connector/
[root@localhost site-packages]#

Installing Protobuf and trying a second time brings with pip3 also fails.  The best solution I found is to install an earlier version: mysql-connector 2.1.4

[root@localhost site-packages]# pip3 install mysql-connector==2.1.4
Collecting mysql-connector==2.1.4
Downloading mysql-connector-2.1.4.zip (355kB)
100% |████████████████████████████████| 358kB 2.3MB/s
Installing collected packages: mysql-connector
Running setup.py install for mysql-connector … done
Successfully installed mysql-connector-2.1.4
[root@localhost site-packages]#

Hopefully I saved you some time installing this module!  Thank you for reading. 





No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment