I am trying to install mysql-python, I have tried two methods in pip
python -m pip install mysql-python
This does not work saying "Failed Building Wheel for MySQL-Python"
Downloading the wheels MySQL_python-1.2.5-cp27-none-win_amd64 and MySQL_python-1.2.5-cp27-none-win32 and trying to install each of them separately with the command
python -m pip install filename
This does not work in each case saying it is "not supported on this platform'
Does any one know what is wrong and how I can install mysql-python?
Update
Since writing this I am still having trouble getting MySQLdb working but have tried a few more things.
1) I am using Python 3.5 mysql-python is for Python 2.x, I should have been trying to install mysqlclient. However I am now having similar issues as above installing mysqlclient both with wheels and with just pip.
> pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\teddy\\appdata\\local\\temp\\pip-build-lhtha0\\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\teddy\appdata\local\temp\pip-stnbio-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\teddy\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\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:\\Users\\teddy\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\teddy\\appdata\\local\\temp\\pip-build-lhtha0\\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\teddy\appdata\local\temp\pip-stnbio-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\teddy\appdata\local\temp\pip-build-lhtha0\mysqlclient\
2) I have tried installing MySQL connector C. This hasn't changed anything.
3) I have tried getting it working on Spyder the IDE that comes with Anaconda
So can anyone suggest anything else
I finally did it. There were two things I changed to get it working:
My Pip was pointing to an older version of Python I had on my
computer and for some reason Idle was picking it up but not Spyder.
I had to move one of the mysql connector files from:
C:\Program Files\MySQL to C:\Program Files (x86)\MySQL
Related
I'm trying to get my mysql integration to django project however when i try to pip install mysqlclient
VSCode throws this error:
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\popcorn\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\popcorn\\AppData\\Local\\Temp\\pip-install-yefz5w6i\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\popcorn\\AppData\\Local\\Temp\\pip-install-yefz5w6i\\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\popcorn\AppData\Local\Temp\pip-record-f55ih7zv\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\popcorn\AppData\Local\Temp\pip-install-yefz5w6i\mysqlclient\
Complete output (30 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
creating build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building 'MySQLdb._mysql' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\MySQLdb
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.22.27905\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,4,'final',0) -D__version__=1.4.4 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -Ic:\users\popcorn\appdata\local\programs\python\python37-32\include -Ic:\users\popcorn\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.22.27905\include" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
_mysql.c
MySQLdb/_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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.22.27905\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\popcorn\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\popcorn\\AppData\\Local\\Temp\\pip-install-yefz5w6i\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\popcorn\\AppData\\Local\\Temp\\pip-install-yefz5w6i\\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\popcorn\AppData\Local\Temp\pip-record-f55ih7zv\install-record.txt' --single-version-externally-managed --compile Check the
logs for full command output.
Anyone know how can i fix this? I've already installed Microsoft Visual C++ pack version 14.22.
The latest release of mysqlclient has wheels for Windows, but they are for 64-bit. If you're on a 64-bit install of Windows I would solve this by installing a 64-bit build of Python. Otherwise it seems to be a bug in the sdist where a header file was accidentally left out.
I have tried 2 commands:
pip install mysql-python
and
pip install mysqlclient
Error for the pip install mysql-python
Command "C:\Users\Pops\Desktop\Martin\Programming\Python\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Pops\\AppData\\Local\\Temp\\pip-install-zfndvw17\\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\Pops\AppData\Local\Temp\pip-reco
rd-jpu7d9zb\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Pops\Desktop\Martin\Programming\Python\venv\include\site\python3.7\mysql-python" failed with er
ror code 1 in C:\Users\Pops\AppData\Local\Temp\pip-install-zfndvw17\mysql-python\
Error for the pip install mysqlclient
Command "C:\Users\Pops\Desktop\Martin\Programming\Python\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Pops\\AppData\\Local\\Temp\\pip-install-cn_nm0np\\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\Pops\AppData\Local\Temp\pip-recor
d-lyzr49kh\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Pops\Desktop\Martin\Programming\Python\venv\include\site\python3.7\mysqlclient" failed with erro
r code 1 in C:\Users\Pops\AppData\Local\Temp\pip-install-cn_nm0np\mysqlclient\
This is the download portion and seems to work fine until the end. (Just putting this here to fill-up more non-code text for stackoverflow to accept the revision)
Top portion prior to error:
Collecting mysqlclient
Downloading https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
100% |████████████████████████████████| 92kB 168kB/s
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command C:\Users\Pops\Desktop\Martin\Programming\Python\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Pops\\AppData\\Local\\Temp\\pip-instal
l-cn_nm0np\\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\Pops\AppD
ata\Local\Temp\pip-record-lyzr49kh\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Pops\Desktop\Martin\Programming\Python\venv\include\site\python3.7\mysql
client:
C:\Users\Pops\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
copying _mysql_exceptions.py -> build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
creating build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -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\Pops\Desktop\Martin\Pro
gramming\Python\venv\include -IC:\Users\Pops\AppData\Local\Programs\Python\Python37-32\include -IC:\Users\Pops\AppData\Local\Programs\Python\Python37-32\include "-IC:\Program Files (x86)\Windows Kits
\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Win
dows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /Tc_mysql.c /Fobuild\temp.win32-3.7\Release\_mysql.obj /Zl
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
You have to add cl.exe into your PATH. It is generally located in (visual studio folder)\VC\bin directory. Add that to your PATH variable using the steps in here.
After this restart the command prompt and you can use cl.exe from command prompt.
Alternatively you can download unofficial windows binaries for mysqlclient from https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient. And Install using pip install "path to the downloaded whl file"
As I mentioned in the comment, you need to cl.exe folder.
You can do it through Visual Studio installer.
Install the following C++ compilers:
try install mysql-python
C:\Users\Одиночка>pip install mysql-python
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\2871~1\\appdata\\local\\temp\\pip-build-lyj5ba\\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\2871~1\appdata\local\temp\pip-y0f9do-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -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:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
error: command 'cl.exe' failed: No such file or directory
I've met this problem too. And I tried the methods listed in Internet and not work. Either install Microsoft Visual Studio with cl.exe in computer or add C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" to PATH. Just didn't work for me. Then as there's error shows in the middle of the error mesg:
error: command 'cl.exe' failed: No such file or directory
.---------------------------------------- Failed building wheel for
Twisted Running setup.py clean for Twisted Failed to build Twisted
It mentioned Twisted, so I install Twisted first and it worked.
You can install the correct version of Twisted in below link:
Unofficial Windows Binaries for Python Extension Packages
I'm using Python 2.7 and Django 1.9.4. I want to integrate my Django application with MySQL 5.7 database and I executed:
pip install MySQL-python
on Windows 7 machine 64-bit.
And getting Error :
F:\Djangoproject\mysite>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:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\chandra\\appdata\\local\\temp\\pip-build
-3qbbxo\\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\chandra\appdata\local\temp\tmpoytuplpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\Chandra\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -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:\python27\include -Ic:\python27\PC /Tc_mys
ql.c /Fobuild\temp.win32-2.7\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:\\Users\\Chandra\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit statu
s 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:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\chandra\\appdata\\local\\temp\\pip-bui
ld-3qbbxo\\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\chandra\appdata\local\temp\pip-rskyc7-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\Chandra\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_in
fo=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python27\include -Ic:\python27\PC /Tc_m
ysql.c /Fobuild\temp.win32-2.7\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:\\Users\\Chandra\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit sta
tus 2
----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\chandra\\appdata\\local\\temp\\pip-build-3qbbxo\\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\chandra\appdata\local\temp\pip-rskyc7-record\install-record.txt --single-version-externally-managed --compile" failed with error code
1 in c:\users\chandra\appdata\local\temp\pip-build-3qbbxo\MySQL-python\
The easiest way is to use precompiled python packages, which can be found here http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
You need a C compiler on your system. The easiest way is to use the on Microsoft provides.
https://www.microsoft.com/en-au/download/details.aspx?id=44266
About Python :
First check is python running properly in command prompt.
If not Download and install python 2.7.
Once it is downloaded, you generally have to go to Control Panel > System > Advanced System Settings > Advanced Tab > Environment Variables > Path > Edit. Here you need to add the Windows path of your Python installation. As an example, mine is “C:\Python27”. If you don’t add this to the Path variable, you won’t be able to run Python from the command line and it’ll be annoying to test things.
Install pip :
Next, we should install pip, the Python package manager (some of this section is from experience some from this stackoverflow page). In case you were wondering, Python 3.4 already has pip installed with it! But if you don’t have it there are a few options. If you have easy_install on your machine, you can simply navigate to the Python27\Scripts directory and type:
easy_install.exe pip
This should install pip for you. If you don’t have easy_install, you can download a python script from here. Make sure to save that get-pip.py file as a .py file not .txt. You can then run the script:
python get-pip.py
Once pip is installed, you can add the directory where pip is to your path like we did before (probably something like “C:\Python27\Scripts”).
About MySQL:
pip install mysql-python
You may get the error Unable to find vcvarsall.bat either when installing pip or other packages (I got it from trying to install mysql-python package). This means Windows can’t find a C/C++ compiler (it’s looking for Visual Studio) which pip uses to install packages and install itself.
Finally test it :
You can check if mysql-python is correctly installed by going to the command prompt and typing:
C:\> python
>>>import MySQLdb
Done with alot of research, even downloaded unofficial windows binaries for python extensions - again made disappointment.
Finally, after trying simply following command and it worked.
easy_install mysql-python
Best way is to install mysqlclient in the case of getting errors in installing mysql-python. mysqlclient is a fork of it and hence it can be used as a substitute and it contains MySQLdb aswell. So, better go for it
I have this error from my installation of mysql-python module for django on a Windows Vista platform:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I have gone through the errors 'spat' out and tried to locate the config-w.h file VC compiler is looking for but to no avail and I'm not sure what to do next (update VC compiler (v9) or remove version and stick with lower version 8 [already on system]).
Raw output:
Collecting MYSQl-python
Using cached MySQL-python-1.2.5.zip
Installing collected packages: MYSQl-python
Running setup.py install for MYSQl-python
Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\i0101010\\appdata\\local\\temp\\pip-build-1vscsn\\MYSQl-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\i0101010\appdata\local\temp\pip-zui5a7-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -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:\Python27\include -IC:\Python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\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\\Microsoft Visual Studio 9.0\\VC\\BIN\\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\i0101010\\appdata\\local\\temp\\pip-build-1vscsn\\MYSQl-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\i0101010\appdata\local\temp\pip-zui5a7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\i0101010\appdata\local\temp\pip-build1vscsn\MYSQl-python
Screenshot:
I managed to get around the issue using easy_install instead. This solved my problem - do not rely solely on pip :)
easy_install MYSQL-python