MySQL-python 安裝出現的問題

來源:互聯網
上載者:User

標籤:

在linux下安裝一個mysqldb,用來讓python能讀寫mysql, 出現的問題

系統內容

1.Oracle Linux 6.5

2.mysql community 5.7.9

3.python default 2.6.6

4.MySQL_python-1.2.3

安裝

1.安裝MySQL-python

解壓tar zxvf MySQL-python-1.2.3.tar.gz

進入目錄

2.python setup.py build 編譯

這個時候,有可能需要裝setuptool,gcc,如果提示找不到類似mysqlclient的提示

大家可以執行

ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a
ln -s /usr/lib64/mysql/libmysqlclient_r.a /usr/lib/libmysqlclient_r.a

具體原因我也不是很清楚,其實如果能把預設目錄換到/usr/lib64下,最好了

至於threadsafe也不用改成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/bin/mysql_config


把mysql_config這個目錄換一下,可以用whereis mysq_config尋找的

 

python setup.py install(還是需要這一步的,大家不要忘記了)

 

3.如果提示

如果提示這個的話,大家不用怕,我也從這裡跌倒的

經查得知是由於編譯Python所用的編譯器與編譯MySQL-python所用編譯器不同所致。
用g++重新編譯_mysql.so即可

如果發現你的機器沒有g++或者用yum install g++不行的情況下

你需要yum install gcc-c++ libstdc++-devel這個就可以了

首先要進入mysql-python的build目錄裡,我的是2.6,你要根據自己的改一下

 g++ -pthread -shared ./temp.linux-x86_64-2.6/_mysql.o -L/usr/lib64 -l mysqlclient_r -lpthread -lm -lrt -ldl -o ./lib.linux-x86_64-2.6/_mysql.so

然後重新編譯就可以了

 

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.