2011-03-12 66 views
18

我試圖安裝Mysql-python on windows x64Python:如何在Windows 7 x64上安裝mysqldb?

我安裝蟒蛇64setuptools的(在 LIB檢查,安裝成功),但我不能安裝MySQLdb的。 我試圖執行

C:\用戶\ Fedcomp \桌面\葉0.4 \ MySQL的 - 蟒蛇-1.2.3>蟒蛇 的setup.py安裝

但趕上這

In file included from _mysql.c:34: 
D:\servers\xampp_server\xampp\mysql\include/config-win.h:211:1: warning: "finite 
" redefined 
D:\servers\xampp_server\xampp\mysql\include/config-win.h:164:1: warning: this is 
the location of the previous definition 
D:\servers\xampp_server\xampp\mysql\include/config-win.h:277:1: warning: "HAVE_S 
TDDEF_H" redefined 
In file included from D:\Python27\include/Python.h:8, 
       from pymemcompat.h:10, 
       from _mysql.c:29: 
D:\Python27\include/pyconfig.h:673:1: warning: this is the location of the previ 
ous definition 
error: command 'gcc' failed with exit status 1 

也與MSVC嘗試,但趕上這(安裝微軟的Visual快遞)

C:\Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3>python setup.py install bui 
ld --compiler=msvc 
running install 
running bdist_egg 
running egg_info 
writing MySQL_python.egg-info\PKG-INFO 
writing top-level names to MySQL_python.egg-info\top_level.txt 
writing dependency_links to MySQL_python.egg-info\dependency_links.txt 
reading manifest file 'MySQL_python.egg-info\SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
warning: no files found matching 'MANIFEST' 
warning: no files found matching 'ChangeLog' 
warning: no files found matching 'GPL' 
writing manifest file 'MySQL_python.egg-info\SOURCES.txt' 
installing library code to build\bdist.win-amd64\egg 
running install_lib 
running build_py 
copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb 
running build_ext 
building '_mysql' extension 
error: Unable to find vcvarsall.bat 

如何在Windows x64上正確安裝mysqldb? (頭從原來的MySQL安裝,因爲在XAMPP服務器,他們不存在)

或者可能有人爲Windows編譯蟒蛇64蟒蛇86MySQLdb的

回答

35

編輯mysqlclientPyPI上有32位和64位的二進制包。這是在MySQL-python的,因爲2014年

原來的答覆爲後人留下了還沒有見過一個釋放的叉:

你可以找到二進制安裝here(Python的2.6-3.2),here(2.7)或here(2.6)。請注意,您不必在Windows x64上使用64位Python。您也可以使用Python的32位版本,爲此,還有更多預構建的第三方軟件包。

+0

+1找到了。我會支持使用32位的建議。它確實讓生活更輕鬆。 – 2011-03-12 17:48:15

+0

如果您已經安裝了另一個版本,那麼我會建議先刪除並安裝正確的版本。 – 2013-05-20 11:05:20

+0

只是一個小小的評論:我試過第一個鏈接,它無法連接到我的數據庫(版本爲Python 2.7)。但第二個鏈接的驅動程序正常工作。 – dbf 2013-10-19 17:57:28

1

「無法找到vcvarsall.bat」意味着您的路徑中沒有必要的Visual Studio目錄。

但是,如果您使用的是64位Python,那麼您將需要一個64位編譯器,並且Express不會採用64位版本。您可以下載SDK MSVC編譯器並獲得配置,但非常辛苦。

如果我是你,我會切換到32位的Python,你幾乎可以肯定會得到預先構建的二進制文件。

編輯

預建如發現piquadrat會更簡單的64位二進制文​​件!

1

我不是100%確定,但我認爲你的路徑變量是怪罪。它似乎沒有找到編譯器,運行搜索vcvarsall.bat並雙擊它,它應該正確設置您的路徑變量。然後嘗試再次安裝你的軟件包。 如果找不到vcvarsall.bat,請重新安裝MS Visual Express。

+4

從這裏試試預編譯的x64版本的MySQL-python:[用於Python擴展包的非官方Windows二進制文件](http://www.lfd.uci.edu/~gohlke/pythonlibs/) – 2011-03-12 18:04:56