标签:python
python环境已经安装好,版本为2.7.8,需要调用数据库,所以需要安装MysqlDB模块包
下载地址:http://download.csdn.net/download/fhqsse220/5602861
安装过程:
解压及安装
# tar -xf MySQL-python-1.2.3.tar.gz
#cd MySQL-python-1.2.3
#python setup.py build
#python setup.py install
2.错误解决
导入模块报错:
/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.pyc, but /soft/MySQL-python-1.2.3 is being added to sys.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
创建动态库的链接:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
&
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
重新导入:
/usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg/_mysql.pyc, but /root/soft/MySQL-python-1.2.3 is being added to sys.path
离开当前目录,因为当前目录有相关模块
本文出自 “运维菜鸟” 博客,请务必保留此出处http://ckl893.blog.51cto.com/8827818/1722899
标签:python
原文地址:http://ckl893.blog.51cto.com/8827818/1722899