標籤:位置 1.2 mod stdin erro stat config setup 軟體包
[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# gcc -v 查看是否安裝gcc 若報錯則未安裝
[[email protected] ~]# yum -y install gcc 安裝gcc
[[email protected] ~]# wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz?use_mirror=ncu 下載軟體包
[[email protected] ~]# tar zxvf MySQL-python-1.2.4b4.tar.gz cd MySQL-python-1.2.4b4 解壓軟體包
解壓包複製到 /usr/local/src/ 下
進入 /usr/local/src/MySQL-python-1.2.4b4
[[email protected] MySQL-python-1.2.4b4]# find / -name mysql_config 查看 mysql_config 檔案位置/usr/local/mysql/bin/mysql_config [[email protected] ~]# vim site.cfg 進入site.cfg 設定檔進行修改
# embedded: link against the embedded server library # threadsafe: use the threadsafe client # static: link against a static library (probably required for embedded)
embedded = False
threadsafe = False (改為False)
static = False
# The path to mysql_config. # Only use this if mysql_config is not on your PATH, or you have some weird # setup that requires it.
mysql_config = /usr/local/mysql/bin/mysql_config (前面的#去掉,並把路徑更改正確)
最後進行安裝:
# python setup.py build
# python setup.py install完畢之後 進入python >>> import MySQLdb若出錯:Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory 根據最後提示,應該是找不著一個交libmysqlclient.so.20的檔案,於是到mysql安裝目錄裡找到這個檔案並且做一個軟串連到/usr/lib[[email protected] lib]# ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib/libmysqlclient.so.20 再次匯入模組就成功了
mysql-python 安裝