Snow Leopard 安装 Python MySQLdb 记录


1. 下载 mysql-python from sf.net

2. 解压,进入解压后的目录。

Input:
cd MySQL-python-1.2.3c1
python setup.py build

Output:
...
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.6-universal-2.6
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 -I/Applications/MAMP/Library/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -fno-omit-frame-pointer -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
_mysql.c:36:23: error: my_config.h: No such file or directory
_mysql.c:38:19: error: mysql.h: No such file or directory
...

Input:
export C_INCLUDE_PATH=/usr/local/mysql/include/
export LIBRARY_PATH=/usr/local/mysql/lib/
python setup.py build

Output:
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc -arch x86_64 build/temp.macosx-10.6-universal-2.6/_mysql.o -L/Applications/MAMP/Library/lib/mysql -lmysqlclient_r -lz -lm -o build/lib.macosx-10.6-universal-2.6/_mysql.so
ld: warning: in /usr/local/mysql/lib/libmysqlclient_r.dylib, file was built for i386 which is not the architecture being linked (ppc)
ld: warning: in /usr/local/mysql/lib/libmysqlclient_r.dylib, file was built for i386 which is not the architecture being linked (x86_64)

Input:
sudo python setup.py install

Output:
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
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.6-universal/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
creating build/bdist.macosx-10.6-universal/egg
copying build/lib.macosx-10.6-universal-2.6/.DS_Store -> build/bdist.macosx-10.6-universal/egg
copying build/lib.macosx-10.6-universal-2.6/_mysql.so -> build/bdist.macosx-10.6-universal/egg
copying build/lib.macosx-10.6-universal-2.6/_mysql_exceptions.py -> build/bdist.macosx-10.6-universal/egg
creating build/bdist.macosx-10.6-universal/egg/MySQLdb
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/__init__.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/connections.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb
creating build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/CR.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/ER.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb/constants
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/converters.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/cursors.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/release.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb
copying build/lib.macosx-10.6-universal-2.6/MySQLdb/times.py -> build/bdist.macosx-10.6-universal/egg/MySQLdb
byte-compiling build/bdist.macosx-10.6-universal/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.6-universal/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.6-universal/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.6-universal/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.6-universal/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-universal/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-universal/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.6-universal/egg/EGG-INFO
writing build/bdist.macosx-10.6-universal/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg' and adding 'build/bdist.macosx-10.6-universal/egg' to it
removing 'build/bdist.macosx-10.6-universal/egg' (and everything under it)
Processing MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg
Removing /Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg
Copying MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg to /Library/Python/2.6/site-packages
Adding MySQL-python 1.2.3c1 to easy-install.pth file

Installed /Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg
Processing dependencies for MySQL-python==1.2.3c1
Finished processing dependencies for MySQL-python==1.2.3c1

Input:
ipython

In [2]: import MySQLdb

In [3]: dir(MySQLdb)
Out[3]:
['BINARY',
'Binary',
'Connect',
'Connection',
'DATE',
'DATETIME',
'DBAPISet',
'DataError',
'DatabaseError',
'Date',
'DateFromTicks',
'Error',
'FIELD_TYPE',
'IntegrityError',
'InterfaceError',
'InternalError',
'MySQLError',
'NULL',
'NUMBER',
'NotSupportedError',
'OperationalError',
'ProgrammingError',
'ROWID',
'STRING',
'TIME',
'TIMESTAMP',
'Time',
'TimeFromTicks',
'Timestamp',
'TimestampFromTicks',
'Warning',
'__all__',
'__author__',
'__builtins__',
'__doc__',
'__file__',
'__loader__',
'__name__',
'__package__',
'__path__',
'__revision__',
'__version__',
'_mysql',
'apilevel',
'connect',
'connection',
'constants',
'debug',
'escape',
'escape_dict',
'escape_sequence',
'escape_string',
'get_client_info',
'paramstyle',
'release',
'result',
'server_end',
'server_init',
'string_literal',
'test_DBAPISet_set_equality',
'test_DBAPISet_set_equality_membership',
'test_DBAPISet_set_inequality',
'test_DBAPISet_set_inequality_membership',
'thread_safe',
'threadsafety',
'times',
'version_info']

In [4]:

安装成功!

你可能感兴趣的:(mysql,python,ext,gcc,C#)