win64位安裝python-mysqldb1.2.5

來源:互聯網
上載者:User

標籤:ace   .com   部署   沒有   版本   運行   sys   mpi   imp   

在其他版本的mysqldb裡面時間查詢有問題
最後確定還是在 1.2.5 版本下來解決,需要解決的問題就是這個:
“Cannot open include file: ‘config-win.h‘: No such file or directory” while installing mysql-python

上面是在 1.2.4 版本上的,後來在 1.2.5 上面應該是解決的。但實際上,1.2.5 在Windows 64 位元環境下還是有問題的,原因見後面的說明。

安裝步驟如下:
1.安裝 Microsoft Visual C++ Compiler Package for Python 2.7
下載連結

2.安裝 MySQL Connector C 6.0.2
下載連結

3.下載 MySQL-python 1.2.5 源碼包
下載連結

4.解壓源碼包後,修改 site.cfg 檔案。
實際上,如果你是在32 位系統上部署,那麼通過pip install 安裝MySQL-python 1.2.5 只需進行上面的依賴包安裝即可。
但在 64 位元環境中,就會提示“Cannot open include file: ‘config-win.h‘” 的錯誤。
原因就是 site.cfg 中寫的 MySQL Connector C 為32 位版本。

原來的 site.cfg 檔案內容如下:

引用# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2

修改為:

引用connector = C:\Program Files\MySQL\MySQL Connector C 6.0.2


5.運行 python setup.py install 即可安裝完成。(摘取自http://www.linuxfly.org/windows_install_mysql_python_library/)

我在編譯過程中遇到以下問題:

1)問題: _mysql.c(34) : fatal error C1083: Cannot open include file: ‘config-win.h’: No such file or directory
error: command ‘”C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/cl.exe”‘ failed with exit status 2

原因:原因是安裝MySQL的時候沒有安裝C語言庫。

解決:重新運行MySQL的安裝程式,選擇Modify,把“C Include Files / Lib Files”勾選上,並安裝。

2)問題:Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "C:/MySQL-python-1.2.3/setup_windows.py", line 7, in get_config
    serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options[‘registry_key‘])
WindowsError: [Error 2] The system cannot find the file specified

原因:MySQL for python 1.2.3仍然是在尋找MySQL5.0的版本

解決:1、開啟目錄下site.cfg檔案,修改最後一行為“registry_key = SOFTWARE/MySQL AB/MySQL Server 5.1”
2、開啟setup_windows.py檔案,修改第七行為“serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, ‘SOFTWARE/MySQL AB/MySQL Server 5.1‘)”

3)問題:build/temp.win32-2.7/Release/_mysql.pyd.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
error: command ‘mt.exe’ failed with exit status 31

原因:路徑發生變化?

解決:開啟“你的PYTHON安裝目錄/Lib/distutils/msvc9compiler.py”檔案,找到“ld_args.append(’/MANIFESTFILE:’ + temp_manifest)”這行代碼,將其改為“ld_args.append(’/MANIFEST’)”

(4)當編譯完成以後,就可以輸入setup.py install了,現在終於大功告成了!

可以在DOS環境下輸入以下命令進行測試:

C:/Users/Michael>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>

win64位安裝python-mysqldb1.2.5

聯繫我們

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