mysql提示python没有安装_MySQL-Python安装问题小记

安装完MysqL-python后import加载模块提示以下错误,

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

于是google之,总结一下解决方法:

(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'

google找到答案(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,-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群:1065694478(已满)交流2群:163560250

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值