10.8.3中的Python有3个版本:2.5、2.6、2.7,默认是2.7,已通过defaults改为2.6了
yibintek iMac Book-Pro:~ yibin$ python
Python 2.6.7 (r267:88850, Oct 11 2012, 20:15:00)
[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.
MySQL_python的版本:MySQL-python-1.2.4b4
执行sudo python
setup.py install,输出:
yibintek iMac Book-Pro:MySQL-python-1.2.4b4 yibin$ sudo python
setup.py install
Password:
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template '
MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.8-intel/egg
running install_lib
running build_py
copying MySQLdb/
release.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb
running build_ext
creating build/bdist.macosx-10.8-intel/egg
copying build/lib.macosx-10.8-intel-2.7/
_mysql.so -> build/bdist.macosx-10.8-intel/egg
copying build/lib.macosx-10.8-intel-2.7/
_mysql_exceptions.py -> build/bdist.macosx-10.8-intel/egg
creating build/bdist.macosx-10.8-intel/egg/MySQLdb
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/
__init__.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/
connections.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb
creating build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
__init__.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
CLIENT.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
CR.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
ER.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
FIELD_TYPE.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
FLAG.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/
REFRESH.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/
converters.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/
cursors.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/
release.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/
times.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb
byte-compiling build/bdist.macosx-10.8-intel/egg/
_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/
__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/
connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/
REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/
converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/
cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/
release.py to release.pyc
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/
times.py to times.pyc
creating stub loader for
_mysql.sobyte-compiling build/bdist.macosx-10.8-intel/egg/
_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.8-intel/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.8-intel/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO
writing build/bdist.macosx-10.8-intel/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg' and adding 'build/bdist.macosx-10.8-intel/egg' to it
removing 'build/bdist.macosx-10.8-intel/egg' (and everything under it)
Processing MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg
removing '/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg' (and everything under it)
creating /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg
Extracting MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg to /Library/Python/2.7/site-packages
MySQL-python 1.2.4b4 is already the active version in easy-install.pth
Installed /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg
Processing dependencies for MySQL-python==1.2.4b4
Finished processing dependencies for MySQL-python==1.2.4b4
测试:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/
__init__.py", line 19, in <module>
import _mysql
ImportError: No module named _mysql
为什么出现找不到_mysql这个模块?