我有一个 Amazon Linux EC2 实例,我正在尝试使用 mysql.connector。调用 import mysql.connector
会导致错误。
我安装了 mysql-python:
[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.
但是当我尝试导入 mysql.connector 时出现错误:
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
>>>
如何让 mysql-connector 在 Amazon Linux EC2 中工作?
是否有其他访问 RDS 的方法?
谢谢!
编辑 - 我使用 yum 安装了 mysql-connector,但问题仍然存在:
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.
最佳答案
您安装的是 MySQLdb 而不是 mysql connector python。 要安装 mysql 连接器 python,请转到 http://dev.mysql.com/downloads/connector/python/
关于python - 使用 Amazon Linux 的 Python 2.6.9 上的 mysql.connector 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25091936/