国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MySQL-Python安裝問題小記

2024-07-24 13:06:37
字體:
供稿:網(wǎng)友

這篇文章主要介紹了MySQL-Python安裝問題小記,需要的朋友可以參考下

安裝完mysql-python后import加載模塊提示以下錯誤,

復(fù)制代碼代碼如下:

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

于是google之,總結(jié)一下解決方法:

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

  1. #mysql_config = XXXXXXXXXXXXXXXX 


注釋符號去掉,并填上mysql_config的地址

(2)將mysql/lib下所有關(guān)于libmysqlclient的so文件軟鏈接到/usr/lib下。

  1. ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/lib 
  2. ldconfig 


?這樣在加載
 

  1. 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個開發(fā)包,需要注意的是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 權(quán)限

sudo -i

安裝MySQL-python問題解決

今天在centos安裝MySQL-python,結(jié)果報錯,報錯信息如下:

  1. 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 
  2. running install 
  3. running build 
  4. running build_py 
  5. copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb 
  6. running build_ext 
  7. building '_mysql' extension 
  8. 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 
  9. _mysql.c:44:23: error: my_config.h: No such file or directory 
  10. _mysql.c:46:19: error: mysql.h: No such file or directory 
  11. _mysql.c:47:26: error: mysqld_error.h: No such file or directory 
  12. _mysql.c:48:20: error: errmsg.h: No such file or directory 
  13. _mysql.c:88: error: expected specifier-qualifier-list before ‘MYSQL' 
  14. _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,通過

sudo yum install mysql-devel.x86_64

再次安裝成功

  1. [yunpeng.jiangyp@v010105 ~]$ pip install MySQL-python 
  2. Downloading/unpacking MySQL-python 
  3. Running setup.py egg_info for package MySQL-python 
  4.  
  5. Installing collected packages: MySQL-python 
  6. Running setup.py install for MySQL-python 
  7. building '_mysql' extension 
  8. 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 
  9. 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 
  10.  
  11. Successfully installed MySQL-python 
  12. Cleaning up... 
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 博野县| 永和县| 黄龙县| 包头市| 东乌珠穆沁旗| 赤城县| 汶川县| 长武县| 天峻县| 阿拉善右旗| 长宁县| 五指山市| 突泉县| 西峡县| 巫溪县| 阳信县| 金门县| 如东县| 桓仁| 修文县| 岳西县| 沽源县| 松滋市| 东港市| 长武县| 尚义县| 池州市| 石阡县| 安西县| 无锡市| 华蓥市| 嵩明县| 清镇市| 琼海市| 临海市| 宁波市| 本溪市| 拉萨市| 凤台县| 五峰| 利辛县|