Here is this issue: I attempt to install mysqlclient like so
C:\Users\amccommon349>pip install mysqlclient Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1 cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command c:\users\amccommon349\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\AMCCOM~1\\AppData\\Local\\Temp\\pip-install-qcgo48hf\\mysqlclient\\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\AMCCOM~1\AppData\Local\Temp\pip-record-q4yoftj8\install-record.txt --single-version-externally-managed --compile:
c:\users\amccommon349\appdata\local\programs\python\python36\lib\distutils\d ist.py:261: UserWarning: Unknown distribution option: 'long_description_content_ type'
warnings.warn(msg)
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\compat.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\converters.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\CLIENT.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\ER.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\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\REFRESH.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\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe /c/nologo/Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\users\amccommon349\appdata\local\programs\python\python36\include -Ic:\users\amccommon349\appdata\local\programs\python\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\ProgramFiles (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I made sure I had all of the files needed from visual studios build tools, I downloaded the mysql-python connector, and updated my pip and setup tools. I am a complete beginner to this and would appreciate any input as to how to go about fixing this error.
This is what solved my issue
It is probably installed in the following location
C:\Program Files\MySQL\MySQL Connector C 6.1
MySQL Connector C 6.1
toC:\Program Files (x86)\MySQL\MySQL Connector C 6.1
pip3 install mysqlclient
.Successful. Good Job!
Unsuccessful?
Probably installed in the location
C:\Program Files\MariaDB\MariaDB Connector C 64-bit\include
and Paste into a folder name it as
mariadb
and paste it to the locationC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\
Copy the contents from
C:\Program Files\MariaDB\MariaDB Connector C 64-bit\lib
and Paste into a folder name it as
mariadb
and paste it to the locationpip3 install mysqlclient
.This worked for me
I was trying the same for a Django project. I tried using:
pip install mysql-python
which gave me the following error:
'mysql.h': No such file or directory
.After fiddling with reuqirements.txt which gave me yet another error
Finally using this worked for me:
pip install mysql-connector
import mysql.connector
This is a problem with the 64 bit version of python on Windows 10. The following repaired the problem for me.
After this I was able to install mysqlclient with
pip install mysqlclient
.Hopefully someone will come up with a better solution that doesn't require downgrading to 32 bit because this is not a good solution, it just works. I found a way to work around the mysql issue but ran into the problem again while trying to install channels. It seems python 64 bit is looking for 32 bit libraries instead of 64 bit libraries on windows. So far this solution has solved all of my python build problems on windows.
None of the solutions above worked for me. Apparently I had to downgrade my Python from
3.7.x
to3.6.4
and that solved the problem for me. Downloadlink forpython=3.6.4
.I would recommend to create a new virtual environment for this and not to uninstall your main python. Find extensive documentation on how to create a
venv
here.I wanted to comment on John's answer but my comment was too long so I had to make another answer. Sorry for that.
John, this helped me a lot, thanks. Not properly reading the logs is a bad habit for many people, myself included.
But instead of downloading the mariadb connector (or searching the net for a prebuilt wheel), I managed to do it with oracle's mysql connector. And I prefer to do symbolic links instead of copying files. Here's what I did using windows 10 x64, python 3.8 x64 and oracle's mysql connector x64:
And that's it.
Wasted a lot of time to solve this error i found the solution that worked for me at least.
When i tried to install MYSQL Client
1st error
And also tried to install Django Channels
2nd error
Download Build tools : Microsoft Build Tools
Stack overflow : How to install/select required Build Tools
Installed build tools. (Happy Coding)
@Ralph Ritoch solution worked for me and as well others those getting Mysql Client error.
But i also installed Django Channels so i followed these steps mentioned below
Follow these steps
I also installed Django Channels 2.2.0 and not getting any kind of error.
(Note)
MySQL connector already installed into x86 directory
So i did not changed the directory of MySQL Connector. (You can also check this)
Maybe work for you!
Other Stack solution to change dirctory
Possible Reasons
Why we getting errors.
Thanks to all who posted their solution.