mysql-python 安裝

來源:互聯網
上載者:User

標籤:位置   1.2   mod   stdin   erro   stat   config   setup   軟體包   

[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# gcc -v    查看是否安裝gcc 若報錯則未安裝

[[email protected] ~]# yum -y install gcc    安裝gcc

[[email protected] ~]# wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz?use_mirror=ncu             下載軟體包

 [[email protected] ~]# tar zxvf MySQL-python-1.2.4b4.tar.gz cd MySQL-python-1.2.4b4        解壓軟體包

解壓包複製到 /usr/local/src/ 下

進入 /usr/local/src/MySQL-python-1.2.4b4

[[email protected] MySQL-python-1.2.4b4]# find / -name mysql_config     查看  mysql_config   檔案位置/usr/local/mysql/bin/mysql_config [[email protected] ~]# vim site.cfg   進入site.cfg  設定檔進行修改 

# embedded: link against the embedded server library # threadsafe: use the threadsafe client # static: link against a static library (probably required for embedded)

embedded = False

threadsafe = False  (改為False)

static = False

# The path to mysql_config. # Only use this if mysql_config is not on your PATH, or you have some weird # setup that requires it.

mysql_config = /usr/local/mysql/bin/mysql_config    (前面的#去掉,並把路徑更改正確)

 

最後進行安裝:

# python setup.py build
# python setup.py install完畢之後 進入python >>> import MySQLdb若出錯:Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory 根據最後提示,應該是找不著一個交libmysqlclient.so.20的檔案,於是到mysql安裝目錄裡找到這個檔案並且做一個軟串連到/usr/lib[[email protected] lib]# ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib/libmysqlclient.so.20 再次匯入模組就成功了   

 

mysql-python 安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.