Krishna
Krishna

Reputation: 681

Python - MySQL Connector error in Mac OSX 10.10

import mysql.connector

config = {
    'user' : 'root',
    'passwd' : ' ',
    'host' : 'localhost',
    'raise_on_warnings' : True,
    'use_pure' : False,
    }
cnx = mysql.connector.connect(**config)

cnx.close()

I used this code to check my mysql package that I installed using the installer provided by the mysql

I ran the file in terminal and the result was,

Traceback (most recent call last):
 File "/Users/Krishna/Documents/check.py", line 1, in <module>
   import mysql.connector
ImportError: No module named 'mysql'

Help is highly appreciated.

Upvotes: 12

Views: 10314

Answers (1)

cgseller
cgseller

Reputation: 4043

I don't think the mysql package is part of the MacOSX default install (it was not for me) for the built-in python.

You can solve this via pip

sudo pip install mysql-connector-repackaged

Verify by checking in the Python Library Path to see if you have a package for mysql there. To get your python path, do:

python
import sys
sys.path

Upvotes: 15

Related Questions