python安裝mysqldb

來源:互聯網
上載者:User

標籤:python

python環境已經安裝好,版本為2.7.8,需要調用資料庫,所以需要安裝MysqlDB模組包

:http://download.csdn.net/download/fhqsse220/5602861

安裝過程:

  1. 解壓及安裝

    # 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.