sudo apt-get install python3-mysql.connector
or
pip3 install mysql-connector
this will install mysql.connector for python3 on ubuntu
Answer from Alok on askubuntu.com
» pip install mysql-connector-python
sudo apt-get install python3-mysql.connector
or
pip3 install mysql-connector
this will install mysql.connector for python3 on ubuntu
Ah! The problem you seem to be facing is you can't create virtualenv with python3.
And to install dependencies for python3 environment you run pip3 install package-name
Follow these steps for creating virtualenv in python3 environment:
virtualenv -p /usr/bin/python3 yourenv
source yourenv/bin/activate
pip3 install mysql-connector
If loading via pip install mysql-connector and leads an error Unable to find Protobuf include directory then this would be useful pip install mysql-connector==2.1.4
mysql-connector is obsolete, so use pip install mysql-connector-python. Same here
To install the official MySQL Connector for Python, please use the name mysql-connector-python:
pip install mysql-connector-python
Some further discussion, when we pip search for mysql-connector at this time (Nov, 2018), the most related results shown as follow:
$ pip search mysql-connector | grep ^mysql-connector
mysql-connector (2.1.6) - MySQL driver written in Python
mysql-connector-python (8.0.13) - MySQL driver written in Python
mysql-connector-repackaged (0.3.1) - MySQL driver written in Python
mysql-connector-async-dd (2.0.2) - mysql async connection
mysql-connector-python-rf (2.2.2) - MySQL driver written in Python
mysql-connector-python-dd (2.0.2) - MySQL driver written in Python
mysql-connector (2.1.6)is provided on PyPI when MySQL didn't provide their officialpip installon PyPI at beginning (which was inconvenient). But it is a fork, and is stopped updating, sopip install mysql-connectorwill install this obsolete version.
And now
mysql-connector-python (8.0.13)on PyPI is the official package maintained by MySQL, so this is the one we should install.