Nitzan Wilnai
Nitzan Wilnai

Reputation: 943

mysql.connector error on Python 2.6.9 with Amazon Linux

I have an Amazon Linux EC2 instance and I am trying to use mysql.connector. Calling import mysql.connector results in an error.

I have mysql-python installed:

[ec2-user@ip-10-231-47-166 dashku]$ sudo yum info MySQL-python.x86_64
Loaded plugins: priorities, update-motd, upgrade-helper
Installed Packages
Name        : MySQL-python
Arch        : x86_64
Version     : 1.2.3
Release     : 0.3.c1.1.9.amzn1
Size        : 246 k
Repo        : installed
From repo   : amzn-main
Summary     : An interface to MySQL
URL         : http://sourceforge.net/projects/mysql-python/
License     : GPLv2+
Description : Python interface to MySQL
            : 
            : MySQLdb is an interface to the popular MySQL database server for Python.
            : The design goals are:
            : 
            : -     Compliance with Python database API version 2.0
            : -     Thread-safety
            : -     Thread-friendliness (threads will not block each other)
            : -     Compatibility with MySQL 3.23 and up
            : 
            : This module should be mostly compatible with an older interface
            : written by Joe Skinner and others. However, the older version is
            : a) not thread-friendly, b) written for MySQL 3.21, c) apparently
            : not actively maintained. No code from that version is used in MySQLdb.

but when I try to import mysql.connector I get an error:

Python 2.6.9 (unknown, Mar 28 2014, 00:06:37) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
>>> 

How do I get mysql-connector working in Amazon Linux EC2?

Is there a different way to access RDS?

Thanks!

Edit - I installed mysql-connector using yum, but the problem persists:

sudo yum info mysql-connector-odbc.x86_64
Loaded plugins: priorities, update-motd, upgrade-helper
Installed Packages
Name        : mysql-connector-odbc
Arch        : x86_64
Version     : 5.1.11
Release     : 1.12.amzn1
Size        : 396 k
Repo        : installed
From repo   : amzn-main
Summary     : ODBC driver for MySQL
URL         : http://dev.mysql.com/downloads/connector/odbc/
License     : GPLv2 with exceptions
Description : An ODBC (rev 3) driver for MySQL, for use with unixODBC.

Upvotes: 0

Views: 1770

Answers (1)

Peeyush
Peeyush

Reputation: 726

You have installed MySQLdb and not mysql connector python. To install mysql connector python go to http://dev.mysql.com/downloads/connector/python/

Upvotes: 3

Related Questions