程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL-Python裝置成績小記

MySQL-Python裝置成績小記

編輯:MySQL綜合教程

MySQL-Python裝置成績小記。本站提示廣大學習愛好者:(MySQL-Python裝置成績小記)文章只能為提供參考,不一定能成為您想要的結果。以下是MySQL-Python裝置成績小記正文


裝置完mysql-python後import加載模塊提醒以下毛病,


ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

因而谷歌之,總結一下處理辦法:

(1)在mysql-ython的裝置目次下找到site.cfg,將

#mysql_config = XXXXXXXXXXXXXXXX

正文符號去失落,並填上mysql_config的地址

(2)將mysql/lib下一切關於libmysqlclient的so文件軟鏈接到/usr/lib下。

ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/lib
ldconfig

如許在加載

import _mysql

的時刻就不會失足了

ubuntu 裝置mysql-python碰到的成績

版本是python 2.6

應用easy_install 裝置MySQL-python

easy_install "MySQL-python==1.2.3"
提醒:error: Setup script exited with error: command 'gcc' failed with exit status 1

須要裝置 python-devel
sudo apt-get install python-dev
#apt-get install python-devel
再應用easy_install 裝置便可以

假如應用python setup.py 裝置,提醒mysql_config找不到
EnvironmentError: mysql_config not found
須要裝置上面2個開辟包,須要留意的是apt-get外面是沒有的,我應用新樹德軟件擔保理器裝置

libmysqld-dev
libmysqlclient-dev

裝置完成今後須要修正MySQL-python-1.2.3文件夾上面的setup_posix.py中的第26行,

mysql_config.path = "mysql_config"改成mysql_config的途徑

whereis mysql_config查找途徑

mysql_config.path = "/usr/bin/mysql_config"

再應用
python setup.py build
python setup.py install
便可以

ubuntu root 權限
sudo -i

裝置MySQL-python成績處理

明天在centos裝置MySQL-python,成果報錯,報錯信息以下:

 Running command /home/yunpeng.jiangyp/sys/python/bin/python -c "import setuptools;__file__='/home/admin/jyp/build/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-MH5Aya-record/install-record.txt
 running install
 running build
 running build_py
 copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
 running build_ext
 building '_mysql' extension
 gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/home/yunpeng.jiangyp/sys/python/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
 _mysql.c:44:23: error: my_config.h: No such file or directory
 _mysql.c:46:19: error: mysql.h: No such file or directory
 _mysql.c:47:26: error: mysqld_error.h: No such file or directory
 _mysql.c:48:20: error: errmsg.h: No such file or directory
 _mysql.c:88: error: expected specifier-qualifier-list before ‘MYSQL'
 _mysql.c:102: error: expected specifier-qualifier-list before ‘MYSQL_RES'

谷歌找到謎底(http://stackoverflow.com/questions/13044201/install-mysql-python-return-error-in-centos),須要先裝置mysql-devel.x86_64,經由過程

sudo yum install mysql-devel.x86_64

再次裝置勝利

[yunpeng.jiangyp@v010105 ~]$ pip install MySQL-python
Downloading/unpacking MySQL-python
 Running setup.py egg_info for package MySQL-python
 
Installing collected packages: MySQL-python
 Running setup.py install for MySQL-python
 building '_mysql' extension
 gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/home/yunpeng.jiangyp/sys/python/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
 gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/usr/lib64 -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_mysql.so
 
Successfully installed MySQL-python
Cleaning up...
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved