时间:2021-05-24
安装完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/libldconfig这样在加载
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-pythonDownloading/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-pythonCleaning up...声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1、下载mysql-python官网地址:http://sourceforge.net/projects/mysql-python/2、安装mysql-pyth
一:安装MySQL-python驱动pipinstallmysql二:连接到MySQL服务器的test数据库#!/usr/bin/python#-*-codin
环境配置1:安装mysql,环境变量添加mysql的bin目录环境配置2:python安装MySQL-Python请根据自身操作系统下载安装,否则会报c++co
一、安装MySQL-python复制代码代码如下:#yuminstall-yMySQL-python二、打开数据库连接复制代码代码如下:#!/usr/bin/p
Anaconda下需要使用Python与MySQL数据库进行交互,所以需要import一个mysql-python的包,但是在ipython中引用的时候发现An