Kaushal Sharma
Kaushal Sharma

Reputation: 31

Django pip install mysqlclient error

So, I can't seem to connect mysql with my django It used to give me an error and used to ask me to install visual c++. But then I had already installed it the day before. Scrolled a little higher and noticed that it also mentioned that a file named vcvarsall.bat was missing. I made a few changes in one of the python files (msvc9compliler and wrote the path to C:/Users/Administrator/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0

AS vcvarsall = "C:/Users/Administrator/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0" + "/vcvarsall.bat"

And then when I tried to run the pip install mysqlclient

It game me the following error

(venv) C:\Users\Administrator\PycharmProjects\BugTracker>pip install mysqlclient
Downloading/unpacking mysqlclient
  Running setup.py (path:C:\Users\ADMINI~1\AppData\Local\Temp\1\pip_build_Administrator\mysqlclient\setup.py) egg_info for package mysqlclient

Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient
    building '_mysql' extension
    C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0
) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -IC:\Python34\include -IC:\Python34\include /Tc_mysql.c /Fobuild\temp.win-amd64-3.4\Release\_mys
ql.obj /Zl
    _mysql.c
    _mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
    error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
    Complete output from command C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\1\\pip_build_Administrator\\mysqlclient\\
setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\1\pip-yo6mf7y
u-record\install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build\lib.win-amd64-3.4

copying _mysql_exceptions.py -> build\lib.win-amd64-3.4

creating build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\__init__.py -> build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\compat.py -> build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\connections.py -> build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\converters.py -> build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\cursors.py -> build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\release.py -> build\lib.win-amd64-3.4\MySQLdb

copying MySQLdb\times.py -> build\lib.win-amd64-3.4\MySQLdb

creating build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.4\MySQLdb\constants

copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.4\MySQLdb\constants

running build_ext

building '_mysql' extension

creating build\temp.win-amd64-3.4

creating build\temp.win-amd64-3.4\Release

C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0) -D
__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -IC:\Python34\include -IC:\Python34\include /Tc_mysql.c /Fobuild\temp.win-amd64-3.4\Release\_mysql.o
bj /Zl

_mysql.c

_mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory

error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

----------------------------------------
Cleaning up...
Command C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\1\\pip_build_Administrator\\mysqlclient\\setup.py';exec(compile(ge
tattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\1\pip-yo6mf7yu-record\install-record.t
xt --single-version-externally-managed --compile failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\1\pip_build_Administrator\mysqlclient
Storing debug log for failure in C:\Users\Administrator\pip\pip.log

Highlight being the error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

Does anyone have any suggestions as to what I'm supposed to do now? I feel like I've reached a dead end.

Upvotes: 1

Views: 1252

Answers (1)

Alasdair
Alasdair

Reputation: 309089

If you can upgrade to Python 3.6 (or 3.5), then pip install mysqlclient will use the wheel instead of building from source.

Upvotes: 1

Related Questions