2017-01-24 18 views
1

Python 3.6の下でMYSQLdbをインストールするのは非常に困難です。私は約1日の間これと戦ってきたが、誰かが修正を望んでいたことを望んでいた。注意すでに述べたように、Windows 10、MY SQL Workbench 6.3、PyCharm 2016.3.2、およびPython 3.6を実行しています。まず、PyCharmでMYSQLdbのインポートを含むコードを実行しようとすると、モジュールが見つかりませんというエラーが表示されます。だから、私はもちろん基本的にすべてのバイナリをインストールすることを試みました。ほとんどの場合、私は次のように取得したい:Python 3.6を使用したMYSQLdb

C:\Users\[me]>pip install mysql-python 
Collecting mysql-python 
Using cached MySQL-python-1.2.5.zip 
Building wheels for collected packages: mysql-python 
Running setup.py bdist_wheel for mysql-python ... error 
Complete output from command c:\python36\python.exe -u -c "import 
setuptools, tokenize;__file__='C:\\Users\\[me]\\AppData\\Local\\Temp\\pip-build-90yksnqx\\mysql-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\[me]\AppData\Local\Temp\tmprh_xynj1pip-wheel- --python-tag cp36: 
running bdist_wheel 
running build 
running build_py 
creating build 
creating build\lib.win-amd64-3.6 
copying _mysql_exceptions.py -> build\lib.win-amd64-3.6 
creating build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb 
creating build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
running build_ext 
building '_mysql' extension 
creating build\temp.win-amd64-3.6 
creating build\temp.win-amd64-3.6\Release 
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python36\include -Ic:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl 
_mysql.c 
_mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory 
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2 

Failed building wheel for mysql-python 
Running setup.py clean for mysql-python 
Failed to build mysql-python 
Installing collected packages: mysql-python 
Running setup.py install for mysql-python ... error 
Complete output from command c:\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[me]\\AppData\\Local\\Temp\\pip-build-90yksnqx\\mysql-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\[me]\AppData\Local\Temp\pip-h7ydssnj-record\install-record.txt --single-version-externally-managed --compile: 
running install 
running build 
running build_py 
creating build 
creating build\lib.win-amd64-3.6 
copying _mysql_exceptions.py -> build\lib.win-amd64-3.6 
creating build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb 
copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb 
creating build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants 
running build_ext 
building '_mysql' extension 
creating build\temp.win-amd64-3.6 
creating build\temp.win-amd64-3.6\Release 
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python36\include -Ic:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl 
_mysql.c 
_mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory 
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2 

だから、私もその後、これは罰金、しかしPyCharmで実行まだ運インストールhttp://www.lfd.uci.edu/~gohlke/pythonlibs/#numpyで入手可能な3.6

のための非公式なバイナリをインストールしてみました。

次にPyCharmのpreferences =>プロジェクトインタプリタに入り、そこから直接MYSQLdbをインストールしようとしました。これで、私はこの他のエラーを受け取ります:

Collecting MySQLdb 

Could not find a version that satisfies the requirement MySQLdb (from versions:) 
No matching distribution found for MySQLdb 

私の研究から、これは新しいリリースのPythonを使用したときに起こるようです。誰かが回避策を知っていますか?3.6がサポートされるのですか?

+0

ここをクリックしてくださいhttp://stackoverflow.com/questions/26866147/mysql-python-install-fatal-error –

答えて

1

多くのODBCドライバで完全にサポートされているsqlalchemyを使用しようとします。 mysqldbを使用することで、mysqlconnectorはpython3.xの方が優れています。私はsqliteからmysqlサーバにプロジェクトを移行し、python3.6でうまく動作します。 sqlalchemyは別のODBCと接続するためのソリューションを提供します。

0

私も同じ問題がありました。

私は別の答えのアドバイスに従い、下記のピップ使用SQLAlchemyのになった:私はまだそれで遊ぶことができなかったが、それはエラーなしでインストールしなかったので、ここでは期待している

pip install SQLAlchemy 

を!

-1

私は前にこの問題を持っていたし、私のpython 3.6を使用しているときにだけはmysqlclientをインストールする必要があることが分かった: 1 - フォルダを作成し、virtualenvを超える(virtualenvのmyvenv --pythonのpython3) 2 - Djangoのバージョンをインストールします。 mysqlclient(pip install mysqlclient)をインストールする myvenvフォルダ/ lib/python3.6/site-packagesの中に入ると、MySQLdbモジュールがそこにあることがわかります。