web-dev-qa-db-ja.com

Python:mysqldbをWindows 7 x64にインストールする方法

インストールしようとしていますMysql-python on windows x64

python x64setuptoolsをインストールしました(leaf libで確認、正常にインストールされました)mysqldbをインストールできません=。実行しようとしています

C:\ Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3> python setup.py install

これをキャッチ

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でも試しますが、これをキャッチします(MS Visual expressがインストールされています)

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を正しくインストールする方法(xamppサーバーには存在しないため、元のmysqlインストールのヘッダー)

または誰かがWindows用にコンパイルmysqldbpython x64またはpython x86

18
Fedcomp

[〜#〜] edit [〜#〜]mysqlclientには、32ビットと64ビットの両方のバイナリパッケージがあります PyPI 。これはMySQL-pythonのフォークであり、2014年以降リリースされていません。

後世に残された元の答え:

バイナリインストーラー here (Python 2.6-3.2)、 here (2.7)または here (2.6)を見つけることができます。 Windows x64では64ビットPythonを使用する必要がないことに注意してください。32ビットビルドのPythonを使用することもできます。そのため、事前にビルドされたサードパーティパッケージがさらにあります。

35

100%確実ではありませんが、パス変数に問題があると思います。コンパイラが見つからないようです。vcvarsall.batを検索してダブルクリックすると、パス変数が正しく設定されます。そして、もう一度パッケージをインストールしてみてください。 vcvarsall.batが見つからない場合は、MS Visual Expressを再インストールしてください。

2
user656781

「vcvarsall.batが見つかりません」とは、必要なVisual Studioディレクトリがパスにないことを意味します。

ただし、64ビットのPythonを使用している場合は、64ビットのコンパイラが必要で、Expressには64ビットのフレーバーが付属していません。SDKMSVCコンパイラをダウンロードして構成することもできますが、大変な作業です。

私があなただったら、32ビットPythonに切り替えると、ほぼ確実にビルド済みのバイナリを取得できます。

[〜#〜]編集[〜#〜]

Piquadratが見つけたビルド済みの64ビットバイナリはさらに簡単です!

1
David Heffernan