MySQL-Python安裝問(wèn)題小記
安裝完mysql-python后import加載模塊提示以下錯(cuò)誤,
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
于是google之,總結(jié)一下解決方法:
(1)在mysql-ython的安裝目錄下找到site.cfg,將
#mysql_config = XXXXXXXXXXXXXXXX
注釋符號(hào)去掉,并填上mysql_config的地址
(2)將mysql/lib下所有關(guān)于libmysqlclient的so文件軟鏈接到/usr/lib下。
ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/lib ldconfig
這樣在加載
import _mysql
的時(shí)候就不會(huì)出錯(cuò)了
ubuntu 安裝mysql-python遇到的問(wèn)題
版本是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個(gè)開(kāi)發(fā)包,需要注意的是apt-get里面是沒(méi)有的,我使用新立德軟件包管理器安裝
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 權(quán)限
sudo -i
安裝MySQL-python問(wèn)題解決
今天在centos安裝MySQL-python,結(jié)果報(bào)錯(cuò),報(bào)錯(cuò)信息如下:
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'
google找到答案(http://stackoverflow.com/questions/13044201/install-mysql-python-return-error-in-centos),需要先安裝mysql-devel.x86_64,通過(guò)
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...
相關(guān)文章
idea連接mysql數(shù)據(jù)庫(kù)失敗的幾種解決方案
我們?cè)趯W(xué)習(xí)Mybatis時(shí)需要連接Mysql數(shù)據(jù)庫(kù),使用IDEA無(wú)法連接mysql數(shù)據(jù)庫(kù),下面這篇文章主要給大家介紹了關(guān)于idea連接mysql數(shù)據(jù)庫(kù)失敗的幾種解決方案,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06MYSQL IN 與 EXISTS 的優(yōu)化示例介紹
當(dāng)B表的數(shù)據(jù)集必須小于A表的數(shù)據(jù)集時(shí),用in優(yōu)于exists,當(dāng)A表的數(shù)據(jù)集系小于B表的數(shù)據(jù)集時(shí),用exists優(yōu)于in2014-08-08mysql下為數(shù)據(jù)庫(kù)設(shè)置交叉權(quán)限的方法
由于 SupeSite 需要調(diào)用 Discuz! 和 UCHome 的數(shù)據(jù),所以如果它們不安裝在同一個(gè)數(shù)據(jù)庫(kù),SupeSite 的數(shù)據(jù)庫(kù)用戶(hù)必須要對(duì) Discuz! 和 UCHome 的數(shù)據(jù)庫(kù)有讀取、修改、刪除等權(quán)限。2011-07-07解決MYSQL數(shù)據(jù)庫(kù)命令行分號(hào)不能結(jié)束語(yǔ)句的問(wèn)題
這篇文章主要介紹了解決MYSQL數(shù)據(jù)庫(kù)命令行分號(hào)不能結(jié)束語(yǔ)句的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01計(jì)算機(jī)二級(jí)考試MySQL知識(shí)點(diǎn) mysql alter命令
這篇文章主要為大家詳細(xì)介紹了計(jì)算機(jī)二級(jí)考試MySQL知識(shí)點(diǎn),詳細(xì)介紹了mysql中alter命令的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08mysql root密碼的重設(shè)方法(親測(cè)可用)
這篇文章主要介紹了如何重設(shè)mysql root密碼,需要的朋友可以參考下2014-02-02SpringBoot連接MySQL獲取數(shù)據(jù)寫(xiě)后端接口的操作方法
今天通過(guò)本文給大家介紹SpringBoot連接MySQL獲取數(shù)據(jù)寫(xiě)后端接口的操作方法,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2021-11-11