【发布时间】:2013-01-10 04:03:07
【问题描述】:
可能重复:
How to install MySQLdb (Python data access library to MySQL) on Mac OS X?
虽然在here 之前已经提出过这个问题,但发布的问题和后续答案与 OS X(Snow Leopard)相关,与 OS X Lion 和 OS X Mountain Lion 无关。在 OS X Lion 和 OS X Mountain Lion 中提供了 Python 和 MySQL 补丁,这些补丁会影响在 Mac OS X 10.7 (Lion) 和 Mac OS X 10.8 (Mountain Lion) 上顺利安装 Python-MySQLdb-connector 的过程。这是重复这个问题的唯一原因。如果您运行的是旧版本的 OS X,请随时参考旧问题。
我正在运行 OS X 10.8.2 (Mountain Lion) 并安装了 python 2.7.2 -
==> python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
但是当我在 python 上运行 import MySQLdb 时,它会失败并显示以下消息 -
==> python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
任何意见都会有所帮助。
【问题讨论】:
标签: python mysql-python