標籤: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安裝mysqldb