Unable to find Protobuf include directory during install mysql-connector over pip Unable to find Protobuf include directory during install mysql-connector over pip python python

Unable to find Protobuf include directory during install mysql-connector over pip


I found that this error occurs since version 2.2.3.You can avoid this issue using version 2.1.6.

pip install mysql-connector==2.1.6

try above.


As of 2.2.3, Connector/Python uses a C++ extension that interfaces with a MySQL server with the X plugin enabled, using Protobuf as data interchange format.

So, you need to set up where Protobuf is installed on your system (the library, include and protoc binary paths).

Requirements

  • A C/C++ compiler, such as gcc
  • Protobuf C++ (version >= 2.6.0)
  • Python development files

Installation

You have two options when using pip + pypi:

1) Set environment variables for MYSQLXPB_PROTOBUF_INCLUDE_DIR, MYSQLXPB_PROTOBUF_LIB_DIR and MYSQLXPB_PROTOC.

2) Add --install-option to set these options when using pip:

shell> python install mysql-connector --install-option='--with-protobuf-include-dir=<path>' --install-option='--with-protobuf-lib-dir=<path>' --install-option='--with-protoc=<path>'

Important: Keep in mind that 2.2.3 is a development release.


I also have this issue on my Ubuntu 16.04 and finally can install mysql-connector 2.2.3 with the following steps:

  1. Install these packages via the Ubuntu package manager:

    sudo apt install libprotobuf-dev protobuf-compiler
  2. Set these environment variables:

    export MYSQLXPB_PROTOC=/usr/bin/protocexport MYSQLXPB_PROTOBUF_INCLUDE_DIR=/usr/include/google/protobufexport MYSQLXPB_PROTOBUF_LIB_DIR=/usr/lib/x86_64-linux-gnu
  3. Install the mysql-connector package via the Python package manager:

    pip install mysql-connector

Hope this helps.