mysqlclient icon indicating copy to clipboard operation
mysqlclient copied to clipboard

Not working with python 3.5

Open piyushspss opened this issue 11 years ago • 65 comments

This is the error I get when I try installing mysqlclient. I am using Windows and python 3.5.

Installing 'mysqlclient'
Collecting mysqlclient
  Using cached mysqlclient-1.3.6.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient
    Complete output from command "c:\users\buccaneer\documents\visual studio            2013\Projects\del1\del1\envrm\Scripts\python.exe" -c "import setuptools, tokenize;__file__='C:\\Users\\BUCCAN~1\\AppData\\Local\\Temp\\pip-build-wuhkxhu3\\mysqlclient\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\BUCCAN~1\AppData\Local\Temp\pip-3jbluuk2-record\install-record.txt --single-version-externally-managed --compile --install-headers "c:\users\buccaneer\documents\visual studio 2013\Projects\del1\del1\envrm\include\site\python3.5\mysqlclient":
running install
running build
running build_py
creating build
creating build\lib.win32-3.5
copying _mysql_exceptions.py -> build\lib.win32-3.5
creating build\lib.win32-3.5\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.5\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.5\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.5\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.5\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.5\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.5\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.5\MySQLdb
creating build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.5\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.5\MySQLdb\constants
running build_ext
building '_mysql' extension
error: Unable to find vcvarsall.bat

piyushspss avatar Sep 25 '15 13:09 piyushspss

The reported problem with vcvarsall.bat missing goes away if you install Visual Studio 14.0 with Python Tools for Visual Studio, which is an option under Programming Languages selection.

However, thereafter another problem pops up reelated to missing 'my_config.h':

    building '_mysql' extension
    creating build\temp.win32-3.5
    creating build\temp.win32-3.5\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" "-Ic:\apps\python 3.5\include" "-Ic:\apps\python 3.5\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\WindowsKits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" /Tc_mysql.c /Fobuild\temp.win32-3.5\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(29): fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

leohipp avatar Oct 07 '15 12:10 leohipp

Building MySQL-python on Windows is hard. You should build from source instead of pip install since you need to edit setup.cfg file.

To make pip installable, I built binary wheels for Windows. But I haven't built wheel for Python 3.5 yet. I hope I can build it in near future.

methane avatar Oct 07 '15 13:10 methane

Adding to my own post: my_config.h becomes available after installing MySQL with development option. But even then the building process fails because it looks for the file from C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include although it becomes installed into C:\Program Files\MySQL\MySQL Connector.C 6.1\include.

Perhaps I'll wait until mysqlclient‑1.3.6‑cp35‑none‑win32.whl becomes available at http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient...

leohipp avatar Oct 08 '15 15:10 leohipp

MySQL Connector/C doesn't support VS 2015 yet.

methane avatar Oct 09 '15 07:10 methane

Hi guys, same problem here. Has anyone found out if uninstalling Python tools from VS2015 makes the problem disappear? Or do we just have to wait for the 3.5 package?

For me Python in VS is nice-to-have but not have-to-have.

boolbag avatar Oct 10 '15 22:10 boolbag

I can't build extension module for Python 3.5 for now. I hope new MySQL Connector/C supports VS 2015...

methane avatar Nov 05 '15 06:11 methane

Anyone figured this out yet? I'm using Windows 10, VS 2015, Python 3.5 64bit.

dvf avatar Nov 20 '15 20:11 dvf

ref: http://bugs.mysql.com/bug.php?id=78282

This bug should be fixed for building Python's mysqlclient on Python 3.5

methane avatar Nov 21 '15 09:11 methane

methane, can you explain how? I'm still having difficulty. I'm not using pip rather compiling the project using python setup.py install after modifying site.cfg to point to the correct location of MySQL Connector.

dvf avatar Nov 23 '15 16:11 dvf

Python 3.5 uses VS2015. But current MySQL can't compile under VS2015. So I can't build mysqlclient-python for Python 3.5 without VCRT mismatch.

Since I'm not Windows expert, I can't build dual-VCRT library. And I don't want to support it if I can build it.

methane avatar Nov 23 '15 17:11 methane

Confirming error with VS2015 while trying to install via PyCharm:

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

boolbag avatar Nov 23 '15 20:11 boolbag

It doesn't work for python3.5 on ubuntu 15.04 too. Hand to edit /usr/bin/pip3 so that !#/usr/bin/python3.5 was now !#/usr/bin/python3 before it was able to install

etsalah avatar Dec 11 '15 15:12 etsalah

Up ! Nobody gots answer???

ghost avatar Dec 13 '15 20:12 ghost

This is a issue of MySQL. I can't do anything until they make a new release.

methane avatar Dec 13 '15 22:12 methane

You can just link against the version shipped with mysql, I did it for py3.5/win64, linked against mysqlclient from mysql 5.7.10 http://pyside.markus-ullmann.de/mysqlclient-win/mysqlclient-1.3.7-cp35-none-win_amd64.whl

jokey2k avatar Jan 13 '16 20:01 jokey2k

Thanks @jokey2k . It works for me. Your suggestion saved me much of lost time. I am using Windows 7 and Python 3.5 installed via Anaconda.

ntung avatar Jan 18 '16 22:01 ntung

@jokey2k: strangely enough pip install exits with error "...is not a supported wheel on this platform". I have win7 x64 and python 3.5, but when I run python.exe it is a *32 process. Can this be a reason and when yes, where can I find a 32-bit wheel. In general all three mysql clients advertised by django are NOT compatible with python 3.5. Great! It was nowhere written, and now I am stuck in a middle of a data migration project. Feels like screaming...

Moodjbow avatar Jan 23 '16 16:01 Moodjbow

Thanks @jokey2k! That was just what I have been looking for!

ngreeney avatar Jan 28 '16 17:01 ngreeney

You're welcome :-)

jokey2k avatar Jan 28 '16 20:01 jokey2k

Thanks @jokey2k ! is it also possible to have mysqlclient-1.3.7-cp35-none-win32.whl ?

PhilippePlagnol avatar Feb 04 '16 13:02 PhilippePlagnol