fedora 安裝python mysql

來源:互聯網
上載者:User

標籤:

如果你伺服器環境允許yum,安裝MySQL-python模組就很簡單了。

如果直接安裝不行,先

安裝MySQL-devel後正常運行

yum install mysql-devel

yum install MySQL-python -y
1 yum install MySQL-python -y

 當然也可以源碼安裝該模組

首先安裝 setuptools,下載原始碼包:

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz解壓後python setup.py buildpython setup.py install
12345 wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz解壓後 python setup.py buildpython setup.py install

然後安裝一些擴充庫

yum -y install rpm-build gcc-c++ mysql-devel python-devel
1 yum -y install rpm-build gcc-c++ mysql-devel python-devel

最後安裝MySQL-python

下載原始碼包:wget http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz解壓進入安裝目錄。編輯 site.cfg ,把 mysql_config 那一行取消注釋,並改為: mysql_config = /usr/lib64/mysql/mysql_config (根據自己mysql安裝位置定義)python setup.py buildpython setup.py install
12345678 下載原始碼包:wget http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz解壓進入安裝目錄。編輯 site.cfg ,把 mysql_config 那一行取消注釋,並改為:mysql_config = /usr/lib64/mysql/mysql_config  (根據自己mysql安裝位置定義) python setup.py buildpython setup.py install

測試安裝

[root@woyoo:/tmp/MySQL-python-1.2.3]# pythonPython 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import MySQLdb/usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.pyc, but /tmp/MySQL-python-1.2.3 is being added to sys.path>>>
1234567 [root@woyoo:/tmp/MySQL-python-1.2.3]# pythonPython 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import MySQLdb/usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.pyc, but /tmp/MySQL-python-1.2.3 is being added to sys.path>>>

報出一大堆警告資訊,解決辦法:刪除MySQL-python來源目錄,再測試一下:

 

fedora 安裝python mysql

聯繫我們

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