MySQL Forums
Forum List  »  Connector/Python

In centOS8, import MySQL connector in Python( import mysql.connector) issue
Posted by: bang nanren bang
Date: June 08, 2021 10:36AM

I start to use Python3 to do some code recently. I google and found some post to guide me to install MySQL connector in Python to connect to MySQL.

I login centOS8 as root , and below commands to install and check, it looks ok. [root@mySQLDB2 mypy]# pip3 install mysql-connector-python [root@mySQLDB2 mypy]# pip3 show mysql-connector-python

But when I manually to check if I can import it in Python , It show error as below:

[root@mySQLDB2 ~]# python3 Python 3.6.8 (default, Mar 19 2021, 05:13:41) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information.

import mysql.connector Traceback (most recent call last): File "", line 1, in File "/usr/local/lib64/python3.6/site-packages/mysql/connector/", line 53, in from .connection import MySQLConnection File "/usr/local/lib64/python3.6/site-packages/mysql/connector/", line 35, in import platform File "/usr/lib64/python3.6/", line 116, in import sys, os, re, subprocess File "/usr/lib64/python3.6/", line 137, in import select File "/root/", line 2, in from mysql.connector import Error ImportError: cannot import name 'Error' exit() [root@mySQLDB2 ~]#

I did search and read this issue for past few days and tried different ways , the problem still there.

I install Python in centOS8 as root running"[root@mySQLDB2 ~]# yum install python3".

Any one experienced this? Thanks for any imput.

Options: ReplyQuote

Written By
In centOS8, import MySQL connector in Python( import mysql.connector) issue
June 08, 2021 10:36AM

Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.