Chinaunix首页 | 论坛 | 博客
  • 博客访问: 358019
  • 博文数量: 49
  • 博客积分: 2709
  • 博客等级: 少校
  • 技术积分: 890
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-01 16:19
文章分类

全部博文(49)

文章存档

2013年(1)

2012年(5)

2011年(5)

2010年(5)

2009年(6)

2008年(27)

我的朋友

分类: Python/Ruby

2011-06-04 15:29:19

install python-3.2 and MySQL for Python on centos5

1)os information
[root@vm0 soft]# uname -a
Linux vm0 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux


2)install python-3.2
download python from


#./configure
#make
#make test (i skiped)
#make install


3) install MySQL-for-Python
download davispuh-MySQL-for-Python-3-9680e4b.tar.gz



[root@vm0 soft]# tar -zxvf davispuh-MySQL-for-Python-3-9680e4b.tar.gz
davispuh-MySQL-for-Python-3-9680e4b/
davispuh-MySQL-for-Python-3-9680e4b/.gitignore
davispuh-MySQL-for-Python-3-9680e4b/HISTORY
davispuh-MySQL-for-Python-3-9680e4b/MANIFEST.in
davispuh-MySQL-for-Python-3-9680e4b/MySQL_python.egg-info/
davispuh-MySQL-for-Python-3-9680e4b/MySQL_python.egg-info/SOURCES.txt
davispuh-MySQL-for-Python-3-9680e4b/MySQL_python.egg-info/dependency_links.txt
davispuh-MySQL-for-Python-3-9680e4b/MySQL_python.egg-info/top_level.txt
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/__init__.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/connections.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/CLIENT.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/CR.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/ER.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/FIELD_TYPE.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/FLAG.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/REFRESH.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/constants/__init__.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/converters.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/cursors.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/release.py
davispuh-MySQL-for-Python-3-9680e4b/MySQLdb/times.py
davispuh-MySQL-for-Python-3-9680e4b/README
davispuh-MySQL-for-Python-3-9680e4b/_mysql.c
davispuh-MySQL-for-Python-3-9680e4b/_mysql_exceptions.py
davispuh-MySQL-for-Python-3-9680e4b/doc/
davispuh-MySQL-for-Python-3-9680e4b/doc/FAQ.txt
davispuh-MySQL-for-Python-3-9680e4b/doc/MySQLdb.txt
davispuh-MySQL-for-Python-3-9680e4b/ez_setup.py
davispuh-MySQL-for-Python-3-9680e4b/metadata.cfg
davispuh-MySQL-for-Python-3-9680e4b/pymemcompat.h
davispuh-MySQL-for-Python-3-9680e4b/setup.cfg
davispuh-MySQL-for-Python-3-9680e4b/setup.py
davispuh-MySQL-for-Python-3-9680e4b/setup_common.py
davispuh-MySQL-for-Python-3-9680e4b/setup_posix.py
davispuh-MySQL-for-Python-3-9680e4b/setup_windows.py
davispuh-MySQL-for-Python-3-9680e4b/site.cfg
davispuh-MySQL-for-Python-3-9680e4b/tests/
davispuh-MySQL-for-Python-3-9680e4b/tests/capabilities.py
davispuh-MySQL-for-Python-3-9680e4b/tests/dbapi20.py
davispuh-MySQL-for-Python-3-9680e4b/tests/test_MySQLdb_capabilities.py
davispuh-MySQL-for-Python-3-9680e4b/tests/test_MySQLdb_dbapi20.py
davispuh-MySQL-for-Python-3-9680e4b/tests/test_MySQLdb_nonstandard.py
davispuh-MySQL-for-Python-3-9680e4b/win_build.cmd
[root@vm0 soft]# cd davispuh-MySQL-for-Python-3-9680e4b
[root@vm0 davispuh-MySQL-for-Python-3-9680e4b]#  python setup.py build  
running build
running build_py
creating build
creating build/lib.linux-i686-3.2
copying _mysql_exceptions.py -> build/lib.linux-i686-3.2
creating build/lib.linux-i686-3.2/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-i686-3.2/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-i686-3.2/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-i686-3.2/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-i686-3.2/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-i686-3.2/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-i686-3.2/MySQLdb
creating build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-i686-3.2/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-i686-3.2/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-i686-3.2
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/usr/local/include/python3.2m -c _mysql.c -o build/temp.linux-i686-3.2/_mysql.o -g
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:419:1: warning: "HAVE_MBRTOWC" redefined
In file included from /usr/local/include/python3.2m/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/usr/local/include/python3.2m/pyconfig.h:457:1: warning: this is the location of the previous definition
In file included from _mysql.c:35:
/usr/local/mysql/include/my_config.h:420:1: warning: "HAVE_WCSCOLL" redefined
In file included from /usr/local/include/python3.2m/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/usr/local/include/python3.2m/pyconfig.h:897:1: warning: this is the location of the previous definition
_mysql.c:2723: warning: function declaration isn’t a prototype
gcc -pthread -shared build/temp.linux-i686-3.2/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lpthread -lm -lrt -ldl -o build/lib.linux-i686-3.2/_mysql.cpython-32m.so
[root@vm0 davispuh-MySQL-for-Python-3-9680e4b]#  python setup.py install
running install
/usr/local/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/setuptools/command/easy_install.py:285: UserWarning: Unbuilt egg for MySQL-python [unknown version] (/soft/davispuh-MySQL-for-Python-3-9680e4b)
  self.local_index = Environment(self.shadow_path+sys.path)
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'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.linux-i686-3.2/MySQLdb
running build_ext
creating build/bdist.linux-i686
creating build/bdist.linux-i686/egg
copying build/lib.linux-i686-3.2/_mysql_exceptions.py -> build/bdist.linux-i686/egg
creating build/bdist.linux-i686/egg/MySQLdb
copying build/lib.linux-i686-3.2/MySQLdb/__init__.py -> build/bdist.linux-i686/egg/MySQLdb
copying build/lib.linux-i686-3.2/MySQLdb/converters.py -> build/bdist.linux-i686/egg/MySQLdb
copying build/lib.linux-i686-3.2/MySQLdb/connections.py -> build/bdist.linux-i686/egg/MySQLdb
copying build/lib.linux-i686-3.2/MySQLdb/cursors.py -> build/bdist.linux-i686/egg/MySQLdb
copying build/lib.linux-i686-3.2/MySQLdb/release.py -> build/bdist.linux-i686/egg/MySQLdb
copying build/lib.linux-i686-3.2/MySQLdb/times.py -> build/bdist.linux-i686/egg/MySQLdb
creating build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/__init__.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/CR.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/ER.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/FLAG.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/REFRESH.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/MySQLdb/constants/CLIENT.py -> build/bdist.linux-i686/egg/MySQLdb/constants
copying build/lib.linux-i686-3.2/_mysql.cpython-32m.so -> build/bdist.linux-i686/egg
byte-compiling build/bdist.linux-i686/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/times.py to times.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.linux-i686/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
creating stub loader for _mysql.cpython-32m.so
byte-compiling build/bdist.linux-i686/egg/_mysql.py to _mysql.pyc
creating build/bdist.linux-i686/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.linux-i686/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.linux-i686/egg/EGG-INFO
writing build/bdist.linux-i686/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3-py3.2-linux-i686.egg' and adding 'build/bdist.linux-i686/egg' to it
removing 'build/bdist.linux-i686/egg' (and everything under it)
Processing MySQL_python-1.2.3-py3.2-linux-i686.egg
removing '/usr/local/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-i686.egg' (and everything under it)
creating /usr/local/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-i686.egg
Extracting MySQL_python-1.2.3-py3.2-linux-i686.egg to /usr/local/lib/python3.2/site-packages
MySQL-python 1.2.3 is already the active version in easy-install.pth

Installed /usr/local/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-i686.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3
[root@vm0 davispuh-MySQL-for-Python-3-9680e4b]#
[root@vm0 davispuh-MySQL-for-Python-3-9680e4b]#

[root@vm0 davispuh-MySQL-for-Python-3-9680e4b]# python
Python 3.2 (r32:88445, Aug  3 2011, 20:59:34)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> import MySQLdb as db
>>> conn=db.connect(host="192.168.18.1",user="root",passwd="521521",db="test",charset="utf8")
>>> cur=conn.cursor()
>>> cur.execute("SET NAMES utf8")
0
>>> cur.execute('select count(*) from t11')
1
>>> ucount=cur.fetchone()[0]
>>> print(ucount)
19524
>>> 
阅读(2049) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~