Python中使用MySQL的问题

php中文网
发布: 2016-06-07 16:57:28
原创
1066人浏览过

第二步:可能遇到的错误1、libmysqlclient.so.16: cannot open shared object file: No such file or directory需要安装新的包my

第一步:安装MySQL-python-1.2.2.tar

python setup.py build
python setup.py intstall

第二步:可能遇到的错误

1、libmysqlclient.so.16: cannot open shared object file: No such file or directory

需要安装新的包mysqlclient16-5.1.30-1.el5.remi.i386

或者通过ln -s设置链接

2、 在build的时候需要按照setuptools-0.6b1-py2.4.egg包

% wget -q

% python ez_setup.py
  Downloading
  setuptools/setuptools-0.6b1-py2.4.egg#md5=b79a8a403e4502fbb85ee3f1941735cb
  Processing setuptools-0.6b1-py2.4.egg
  creating /sw/lib/python2.4/site-packages/setuptools-0.6b1-py2.4.egg
  Extracting setuptools-0.6b1-py2.4.egg to /sw/lib/python2.4/site-packages
  Removing setuptools 0.6a11 from easy-install.pth file
  Adding setuptools 0.6b1 to easy-install.pth file
  Installing easy_install script to /sw/bin
  Installing easy_install-2.4 script to /sw/bin

  Installed /sw/lib/python2.4/site-packages/setuptools-0.6b1-py2.4.egg
  Processing dependencies for setuptools

这个按照需要上网,需要设置网络环境ip地址+DNS。

3  EnvironmentError: mysql_config not found

MySQL-python-1.2.2]# vi setup_posix.py
26 mysql_config.path = "/usr/local/mysql/bin/mysql_config"
将26行改为mysql_config的真是路径
再次执行python setup.py build;python setup.py install
就OK了

4 /usr/bin/ld: cannot find -lmysqlclient_r
 解决方法一(已经测试通过)

执行以下命令:

echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf(我的环境是CentOS 5)

ldconfig,,执行以后还是提示以上错误。

———————–

后来看来一下README,原文在下面

——————-

threadsafe
        thread-safe client library (libmysqlclient_r) if True (default);
        otherwise use non-thread-safe (libmysqlclient). You should
        always use the thread-safe library if you have the option;
        otherwise you *may* have problems.

———————————

得知得修改site.cfg,将thread-safe设为false,一切OK!

python setup.py install

解决方法二(没有测试)A thread-safe client library (libmysqlclient_r) will be created automatically during the compilation of MySQL  if the configure command contains the option "--enable-thread-safe-client".

linux

python速学教程(入门到精通)
python速学教程(入门到精通)

python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号