PyMySQL / mysqlclient

MySQL/MariaDB connector for Python
https://mysqlclient.readthedocs.io/
GNU General Public License v2.0
2.45k stars 435 forks source link

Not working with python 3.5 #54

Closed piyushspss closed 8 years ago

piyushspss commented 9 years ago

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
leohipp commented 9 years ago

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
methane commented 9 years ago

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.

leohipp commented 9 years ago

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...

methane commented 9 years ago

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

boolbag commented 9 years ago

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.

methane commented 9 years ago

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

dvf commented 9 years ago

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

methane commented 9 years ago

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

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

dvf commented 8 years ago

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.

methane commented 8 years ago

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.

boolbag commented 8 years ago

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

etsalah commented 8 years ago

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

ghost commented 8 years ago

Up ! Nobody gots answer???

methane commented 8 years ago

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

jokey2k commented 8 years ago

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

ntung commented 8 years ago

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.

Moodjbow commented 8 years ago

@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...

ngreeney commented 8 years ago

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

jokey2k commented 8 years ago

You're welcome :-)

PhilippePlagnol commented 8 years ago

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

ghost commented 8 years ago

Thanks @jokey2k it works for me.

cgohlke commented 8 years ago

I put 32 and 64-bit wheels for Python 3.5 at http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient. These are linked to the multi-threaded DLL runtime (/MD) versions of mysqlclient 5.7.11 for VC14.

adanilins commented 8 years ago

Thank You @cgohlke so much!!!

tomoh1r commented 8 years ago

FYI:

MySQL 5.6.29 was released Changes in MySQL 5.6.29 (2016-02-05)

and from above, it seem to have been resolved VS2015 problem.

methane commented 8 years ago

I'm waiting new release of MySQL Connector/C

PhilippePlagnol commented 8 years ago

thank you so much !!!

boolbag commented 8 years ago

Works a charm via pip install. Wondering if anyone knows a way to install the wheel in a virtualenv in PyCharm? Otherwise no worries, I'll just make it available to the whole of 3.5.

akbarpn136 commented 8 years ago

Thanks @jokey2k. It works for me. I am using Windows 7 64bit and Python 3.5 installed via Anaconda.

ryanhalabi commented 8 years ago

Can someone please explain how to implement @jokey2k 's solution step by step? Thanks.

methane commented 8 years ago

@ryanhalabi

  1. Install MySQL server (amd64) with client library.
  2. Build mysqlclient-python (amd64) with it
  3. Uninstall MySQL server.
  4. Install MySQL server (x86) with client library.
  5. Build mysqlclient-python (x86) with it
  6. Uninstall MySQL server

I know it, but I don't want to do it... Why MySQL developer don't release MySQL Connector/C for such a long time? It's very annoying.

Ihure commented 8 years ago

Thanks @jokey2k the solution worked for me. windows 10, 64 bit system and python 3.5

TalatCikikci commented 8 years ago

thanks @cgohlke ; +100 internets to you :+1:

kryogenic commented 8 years ago

thank you @cgohlke for linking to the 32-bit .whl :D

kreuzberger commented 8 years ago

If you get the error with vcvarsall.bat you could also try to set these environment variables: set DISTUTILS_USE_SDK=1 set MSSdk=1 set PY_VCRUNTIME_REDIST="No Thanks" this works for msvc2013

for later msvc you must set PY_VCRUNTIME_REDIST to a correct path.

This is general the case if you compile modules.

the missing include is fixed after extracting mysql with include directory and setting the INCLUDE environment variable for cl correctly. (also linker variable for sure)

I got it only worky by setting the code page to normal windows code page ("chcp 1252"). Normally i must set it to 65001 cause some modules require this to work.

methane commented 8 years ago

@kreuzberger Do you mean use msvc2013 (VC13) to build Python 3.5 (based on VC14 runtime) extension module? Is it really safe?

kreuzberger commented 8 years ago

no, sorry for the misunderstanding. I compile python myself with vs2013 too. Mixing is no good idea. but its python 3.5 as asked in the questions.

methane commented 8 years ago

Hmmm. Why Oracle doesn't release MySQL Connector/C for VC14 for such a long time.... Very annoying...

carloliwanag commented 8 years ago

Hi @jokey2k. I am new to django, can you please create the instruction on how to use the whl file you have provided? thanks!

methane commented 8 years ago

I've managed to build by myself and uploaded binary wheel for CPython 3.5 amd64. (Building all on Windows from source was not a fun task...)

Can anyone try this?

https://github.com/PyMySQL/mysqlclient-python/releases/download/1.3.7/mysqlclient-1.3.7-cp35-cp35m-win_amd64.whl

methane commented 8 years ago

I succeeded to build MySQL clientlib in MySQL 5.7.15 in this weekend. I'll release next bugfix version with Python 3.5 Win64 binary wheel.

ningquec commented 8 years ago

@methane . I tried your binary wheel but it did't work. ERROR: mysqlclient-1.3.7-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform.

methane commented 8 years ago

@ningquec Do you use CPython 3.5 Win64?

ningquec commented 8 years ago

Yes, i install it in virtual env. but it worked while not venv.

methane commented 8 years ago

pip install -U pip setuptools wheel before pip install mysqlclient-1.3.7-cp35-cp35m-win_amd64.whl?

jameskandau commented 8 years ago

i did it this way.Downloaded the mysqlclient.ie mysqlclient-1.3.4-cp34-none-win_amd64.whl saved it in my downloads. Open your work folder and activate your virtualenv. then run this commad. pip install C:/users/your/user/to/where/mysqlclient/is and thats it. If using django then config your cridentials in settings file.Happy wheeling

methane commented 8 years ago

I've managed to build binary wheel for Python 3.5 and 2.7

https://github.com/PyMySQL/mysqlclient-python/releases/tag/1.3.8

Anyone try these wheel?

oliverqg commented 8 years ago

@jameskandau your suggestion worked for me. I installed mysqlclient-1.3.7-cp35-none-win_amd64.whl and stopped getting the error. I'm using Win10, Python 3.5, Django 1.9.6. So far so good. Thanks!

jameskandau commented 8 years ago

Great if it worked for you. Happy coding On 11 Oct 2016 05:00, "oliverqg" notifications@github.com wrote:

@jameskandau https://github.com/jameskandau your suggestion worked for me. I installed mysqlclient-1.3.7-cp35-none-win_amd64.whl and stopped getting the error. I'm using Win10, Python 3.5, Django 1.9.6. So far so good. Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PyMySQL/mysqlclient-python/issues/54#issuecomment-252791816, or mute the thread https://github.com/notifications/unsubscribe-auth/AKNdoCPUxG-3Y-2PZoa6EHpPx1y0klxRks5qyu3BgaJpZM4GD0mM .

Steven-N commented 8 years ago

Thank you so much @cgohlke you saved me. I've spent an embarrassing amount of hours today getting this working.

danielniccoli commented 8 years ago

I've managed to build binary wheel for Python 3.5 and 2.7 https://github.com/PyMySQL/mysqlclient-python/releases/tag/1.3.8 Anyone try these wheel?

On Windows 10, Python 3.5.2 64-Bit crashes with that binary when trying to run Django's manage.py runserver (1.10.3). Probably noteworthy that I am running MariaDB.

Faulting application name: python.exe, Version: 3.5.1150.1013, time stamp: 0x576f0390 Faulting module name: python35.dll, Version: 3.5.1150.1013, time stamp: 0x576f037c Exception code: 0xc0000005 Fault offset: 0x00000000000e631c

Edit: No issues with _mysqlclient-1.3.7-cp35-cp35m-winamd64.whl