Unable to import mysql.connector in a Python venv session I've used venv to create a virtual environment for Python 3.5.2. I have installed the mysql.connector. The connector works fine as long as I am not in an activated venv environment.

from mysql.connector import MySQLConnection, Error
from python_mysql_dbconfig import read_db_config


With these statements I get the following:

Traceback (most recent call last):
  File "fetchone.py", line 1, in &lt;module&gt;
    from mysql.connector import MySQLConnection, Error
ImportError: No module named 'mysql.connector'


I have searched for a solution but most are dated several years ago. Like I said, the mysql.connector is located and works fine outside of the venv environment
You might want to check out the following article: 

Can not get mysql-connector-python to install in virtualenv (Stackoverflow) 

The accepted answer states the following:


  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