Can not get mysql-connector-python to install in virtualenv

Several things. There is an inconsistency in package naming so you may want to do:

pip search mysql-connector

to find out what it is called on your platform. I got two results mysql-connector-python and mysql-connector-repackaged.

so try this first:

pip install mysql-connector-python

this may additionally give an error like this:

Some externally hosted files were ignored (use 
    --allow-external mysql-connector-python to allow).

so finally this should do the job:

pip install mysql-connector-python --allow-external mysql-connector-python

Solution I found:

sudo pip install mysql-connector-python-rf

If you see this error: option --single-version-externally-managed not recognized, try this:

sudo pip install --egg mysql-connector-python-rf

pip install mysql-connector

This worked for me!


I was facing the similar issue. My env details -
Python 2.7.11
pip 9.0.1
CentOS release 5.11 (Final)

Error on python interpreter -

>>> import mysql.connector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
>>>

Use pip to search the available module -

$ pip search mysql-connector | grep --color mysql-connector-python



mysql-connector-python-rf (2.2.2)        - MySQL driver written in Python
mysql-connector-python (2.0.4)           - MySQL driver written in Python

Install the mysql-connector-python-rf -

$ pip install mysql-connector-python-rf

Verify

$ python
Python 2.7.11 (default, Apr 26 2016, 13:18:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>