Windows Python2.7 mysqldb installation error exit status 2 - windows

I'm trying to install mysqldb for Python. I'm running "pip install mysql-python" and I keep getting this error:
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'fi nal',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 /Fobui ld\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 (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
--------------------------------------
Failed building wheel for mysql-python
Failed to build mysql-python
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\scott~1.sco\appdata\local\temp\pip-bu ild-nja4gr\mysql-python\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install - -record c:\users\scott~1.sco\appdata\local\temp\pip-5htk1y-record\install-record.txt --single-version-externally-managed --compile: running install
running build
running build_py
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
running build_ext
building '_mysql' extension
C:\Program Files (x86)\Common Files\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_mysql.c /Fob uild\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 (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
--------------------------------------
Command "c:\python27\python.exe -c "import setuptools, tokenize;file='c:\users\scott~1.sco\appdata\local\temp\pip-build-nja4gr\mysql-python \setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\scott~1 .sco\appdata\local\temp\pip-5htk1y-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\scott ~1.sco\appdata\local\temp\pip-build-nja4gr\mysql-python
Would someone help? I am new to Python.

That's because you have an Incompatible MySQL-C/Python connector for Python. Latest Connector comes only for Python3.
Just follow these steps:
Download, MySQL-C/Python27 Connector
Install it.
Open CMD as admin.
Type the following in CMD.
mklink /d "C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2" "C:\Program Files\MySQL\MySQL Connector C 6.0.2"
Try installing now, python -m pip install MySQL-Python
TaDa! It works!
This answer is from All of common comments in asked question of this type!

Download the 32-bit version from MySQL-C Download Page
Try installing now, python -m pip install MySQL-Python
Worked perfectly for me. You have to install the 32-bit version even inside a 64-bit Windows environment.

Related

can't install pycocotools "Cannot open include file: 'math.h': No such file or directory" [duplicate]

I'm trying to use object detection models from Tensorflow and need to get pycocotools installed. I'm doing this from a python (3) virtual environment on a Windows 10 machine. There seems to be some known issues around getting this working on Windows, and I'm pretty sure I've tried them all.
I've tried pip-installing pycocotools, with this error (fails building wheel):
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install pycocotools
Collecting pycocotools
Using cached pycocotools-2.0.2.tar.gz (23 kB)
Requirement already satisfied: setuptools>=18.0 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from pycocotools) (56.0.0)
Requirement already satisfied: cython>=0.27.3 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from pycocotools) (0.29.23)
Requirement already satisfied: matplotlib>=2.1.0 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from pycocotools) (3.4.2)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.4.7)
Requirement already satisfied: cycler>=0.10 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (8.2.0)
Requirement already satisfied: numpy>=1.16 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.19.5)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.3.1)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.8.1)
Requirement already satisfied: six in c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages (from cycler>=0.10->matplotlib>=2.1.0->pycocotools) (1.15.0)
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\la01043601\AppData\Local\Temp\pip-wheel-i_wesduj'
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-install-hjka7e0k\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\
Complete output (23 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools
running build_ext
cythoning pycocotools/_mask.pyx to pycocotools\_mask.c
c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\la01043601\AppData\Local\Temp\pip-install-hjka7e0k\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\pycocotools\_mask.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\common
creating build\temp.win-amd64-3.9\Release\pycocotools
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I./common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc./common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\./common/maskApi.obj
maskApi.c
./common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pycocotools
Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
Running setup.py install for pycocotools ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-crzypf9k\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools'
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-install-hjka7e0k\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\
Complete output (21 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools
running build_ext
skipping 'pycocotools\_mask.c' Cython extension (up-to-date)
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\common
creating build\temp.win-amd64-3.9\Release\pycocotools
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I./common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc./common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\./common/maskApi.obj
maskApi.c
./common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-install-hjka7e0k\\pycocotools_91d3c7ee2ad946f292455cc0fc685c5f\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-crzypf9k\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools' Check the logs for full command output.
I've tried the fix from Phil Ferriere's repository (still fails building wheel, something with math.h file not found):
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Cloning https://github.com/philferriere/cocoapi.git to c:\users\la01043601\appdata\local\temp\pip-req-build-htao1r08
Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08'
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\la01043601\AppData\Local\Temp\pip-wheel-kktx8s70'
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08\PythonAPI
Complete output (20 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\common
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\pycocotools
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I../common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
maskApi.c
../common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pycocotools
Running setup.py clean for pycocotools
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08\PythonAPI\setup.py", line 25, in <module>
cythonize(ext_modules)
File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 965, in cythonize
module_list, module_metadata = create_extension_list(
File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
raise ValueError(error_msg)
ValueError: 'pycocotools/_mask.pyx' doesn't match any files
----------------------------------------
ERROR: Failed cleaning build dir for pycocotools
Failed to build pycocotools
Installing collected packages: pycocotools
Running setup.py install for pycocotools ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-ok0x1q7g\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools'
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-htao1r08\PythonAPI
Complete output (9 lines):
running install
running build
running build_py
running build_ext
building 'pycocotools._mask' extension
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I../common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
maskApi.c
../common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-htao1r08\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\la01043601\AppData\Local\Temp\pip-record-ok0x1q7g\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\la01043601\ml_cameravision\humandetection\env\include\site\python3.9\pycocotools' Check the logs for full command output.
I've tried installing Visual C++ Build Tools (2015 version recommended by many other answers), but got the error that it was unable to find/download setup package, so I've made sure I have updates to the 2019 build tools, and they are added to my path.
Error I was getting is like this one. I also followed the video at the bottom of that solution and it didn't help.
I've tried using the suggested windows install for pycocotools (pycocotools-windows), which gives the following error:
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install cocoapi-windows
ERROR: Could not find a version that satisfies the requirement cocoapi-windows (from versions: none)
ERROR: No matching distribution found for cocoapi-windows
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install pycocotools-windows
ERROR: Could not find a version that satisfies the requirement pycocotools-windows (from versions: none)
ERROR: No matching distribution found for pycocotools-windows
Python and pip are on my Windows path. I gave up on one tutorial due to this, just to find the next one has a pycocotools dependency too.
(Also accepting suggestions for Tensorflow object detection tutorials that do not use pycocotools! Need a decent tutorial because I'm a beginner).
Edit: Have now also tried running the setup.py file the following way, still having issues with not finding a math.h file...
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection\sandbox\cocoapi\PythonAPI> python setup.py build_ext --inplace
Compiling pycocotools/_mask.pyx because it changed.
[1/1] Cythonizing pycocotools/_mask.pyx
C:\Users\la01043601\ML_CameraVision\humanDetection\env\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\la01043601\ML_CameraVision\humanDetection\sandbox\cocoapi\PythonAPI\pycocotools\_mask.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'pycocotools._mask' extension
creating build
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\common
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\pycocotools
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\la01043601\ML_CameraVision\humanDetection\env\lib\site-packages\numpy\core\include -I../common -IC:\Users\la01043601\ML_CameraVision\humanDetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
maskApi.c
../common/maskApi.c(8): fatal error C1083: Cannot open include file: 'math.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
Edit edit I forgot to mention that in the past couple days I also tried troubleshooting the math.h error, which suggests switching an include statement from "math.h" to "cmath", and using "quotes" instead of angle brackets, and since this happens when installing from a downloaded repo I even forked the repo the made the change on my version to download from there. Error as follows (now related to a missing 'crtdbg.h' file and I don't understand how everything works under the hood in Build Tools):
(env) PS C:\Users\la01043601\ML_CameraVision\humanDetection> pip install git+https://github.com/Broccoli-Hunter/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/Broccoli-Hunter/cocoapi.git#subdirectory=PythonAPI
Cloning https://github.com/Broccoli-Hunter/cocoapi.git to c:\users\la01043601\appdata\local\temp\pip-req-build-atepfcnd
Running command git clone -q https://github.com/Broccoli-Hunter/cocoapi.git 'C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd'
Building wheels for collected packages: pycocotools
Building wheel for pycocotools (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\la01043601\AppData\Local\Temp\pip-wheel-4bje9txk'
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd\PythonAPI
Complete output (20 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\pycocotools
copying pycocotools\coco.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\mask.py -> build\lib.win-amd64-3.9\pycocotools
copying pycocotools\__init__.py -> build\lib.win-amd64-3.9\pycocotools
running build_ext
building 'pycocotools._mask' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\common
creating build\temp.win-amd64-3.9\Release
creating build\temp.win-amd64-3.9\Release\pycocotools
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\numpy\core\include -I../common -Ic:\users\la01043601\ml_cameravision\humandetection\env\include -IC:\Python39\include -IC:\Python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include /Tc../common/maskApi.c /Fobuild\temp.win-amd64-3.9\Release\../common/maskApi.obj
maskApi.c
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include\yvals.h(12): fatal error C1083: Cannot open include file: 'crtdbg.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pycocotools
Running setup.py clean for pycocotools
ERROR: Command errored out with exit status 1:
command: 'c:\users\la01043601\ml_cameravision\humandetection\env\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"'; __file__='"'"'C:\\Users\\la01043601\\AppData\\Local\\Temp\\pip-req-build-atepfcnd\\PythonAPI\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
cwd: C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\la01043601\AppData\Local\Temp\pip-req-build-atepfcnd\PythonAPI\setup.py", line 25, in <module>
cythonize(ext_modules)
File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 965, in cythonize
module_list, module_metadata = create_extension_list(
File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
File "c:\users\la01043601\ml_cameravision\humandetection\env\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
raise ValueError(error_msg)
ValueError: 'pycocotools/_mask.pyx' doesn't match any files
----------------------------------------
ERROR: Failed cleaning build dir for pycocotools
Failed to build pycocotools
I managed to install pycocotools only after downloading the installer from this link and installing these:
me too! I ran "pip install pycocotools" on Linux, same error like this:
running build_ext
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/common
creating build/temp.linux-x86_64-3.7/pycocotools
gcc -pthread -B /home/ppp/anaconda3/envs/openmmlab/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-env-qzv5sdb4/overlay/lib/python3.7/site-packages/numpy/core/include -I./common -I/home/ppp/anaconda3/envs/openmmlab/include/python3.7m -c ./common/maskApi.c -o build/temp.linux-x86_64-3.7/./common/maskApi.o -Wno-cpp -Wno-unused-function -std=c99
./common/maskApi.c:8:18: fatal error: math.h: No such file or directory
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for pycocotools
Failed to build pycocotools
ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
I solved the problem by conda install pycocotools -c conda-forge
ps: python version==3.7.12
after everything failed, I installed visual c++ build tools using the link below
Visit https://myvs.download.prss.microsoft.com/db/mu_visual_cpp_build_tools_2015_update_3_x64_dvd_dfd9a39c.iso?t=36429cde-dc63-4657-8114-1c74ae0da9bf&e=1645739068&h=e153f9afa2fa5fd4ffae5a1cc714a2ab704115af952dfb82e1761e5553c7999a&su=1
after it has downloaded open it and run the setup file, everything should run smoothly.
Then in your environment run this code:-
pip install cython
then this one:
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
that should work, I am using TensorFlow version 2.3, Python 3.8
You may need to install:
sudo apt install python3.9-dev
Place another python version if you need 3.8 etc.
Then pycocotools is installed correctly, helped in my case when "Python.h" was not found.
Don't Forget to Restart your pc after install visual c++ build tools, in my case everything not working until I restart my PC after installing the build tools.

I can't install PyBluez on PyCharm Windows 10

I've last PyCharm version and I use Python 3.6.1
When I'm trying to install a PyBluez 0.22 I get error message
Here is my error details:
Collecting PyBluez
Using cached PyBluez-0.22.zip
Installing collected packages: PyBluez
Running setup.py install for PyBluez: started
Running setup.py install for PyBluez: finished with status 'error'
Complete output from command "C:\Python 3.6.1\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\m-grz\\AppData\\Local\\Temp\\pycharm-packaging\\PyBluez\\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\m-grz\AppData\Local\Temp\pip-eqci78cu-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-3.6
creating build\lib.win32-3.6\bluetooth
copying bluetooth\ble.py -> build\lib.win32-3.6\bluetooth
copying bluetooth\bluez.py -> build\lib.win32-3.6\bluetooth
copying bluetooth\btcommon.py -> build\lib.win32-3.6\bluetooth
copying bluetooth\msbt.py -> build\lib.win32-3.6\bluetooth
copying bluetooth\osx.py -> build\lib.win32-3.6\bluetooth
copying bluetooth\widcomm.py -> build\lib.win32-3.6\bluetooth
copying bluetooth\__init__.py -> build\lib.win32-3.6\bluetooth
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'bluetooth._msbt' extension
creating build\temp.win32-3.6
creating build\temp.win32-3.6\Release
creating build\temp.win32-3.6\Release\msbt
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include" -I.\port3 "-IC:\Python 3.6.1\include" "-IC:\Python 3.6.1\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" /Tcmsbt\_msbt.c /Fobuild\temp.win32-3.6\Release\msbt\_msbt.obj
_msbt.c
msbt\_msbt.c(1): fatal error C1083: Cannot open include file: 'winsock2.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
----------------------------------------
Command ""C:\Python 3.6.1\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\m-grz\\AppData\\Local\\Temp\\pycharm-packaging\\PyBluez\\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\m-grz\AppData\Local\Temp\pip-eqci78cu-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\m-grz\AppData\Local\Temp\pycharm-packaging\PyBluez\
I'll be very grateful for your help!

Pip install tesseract-ocr : failed with exit status 2

I've been trying to install Tesseract-ocr library for a long time. Read many similar problems related with other packages and given solutions and none worked.
I think problem is about the my Microsoft Visual Studio. There is an error given the code below:
error: command 'c:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\Bin\x86_amd64\cl.exe' failed with exit status 2
I uninstalled, reinstalled, updated and tried many things but still not working :(
Thanks already now!
C:\Users\af>pip install tesseract-ocr
Collecting tesseract-ocr
Using cached tesseract-ocr-0.0.1.tar.gz
Requirement already satisfied: cython in c:\python34\lib\site-packages (from tesseract-ocr)
Building wheels for collected packages: tesseract-ocr
Running setup.py bdist_wheel for tesseract-ocr ... error
Complete output from command c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\af\\AppData\\Local\\Temp\\pip-build-ggf9qvw1\\tesseract-ocr\\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\af\AppData\Local\Temp\tmpdnkpad7cpip-wheel- --python-tag cp34:
running bdist_wheel
running build
running build_py
file tesseract_ocr.py (for module tesseract_ocr) not found
file tesseract_ocr.py (for module tesseract_ocr) not found
running build_ext
building 'tesseract_ocr' extension
creating build
creating build\temp.win-amd64-3.4
creating build\temp.win-amd64-3.4\Release
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\python34\include -Ic:\python34\include /Tptesseract_ocr.cpp /Fobuild\temp.win-amd64-3.4\Release\tesseract_ocr.obj
tesseract_ocr.cpp
tesseract_ocr.cpp(463) : fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Failed building wheel for tesseract-ocr
Running setup.py clean for tesseract-ocr
Failed to build tesseract-ocr
Installing collected packages: tesseract-ocr
Running setup.py install for tesseract-ocr ... error
Complete output from command c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\af\\AppData\\Local\\Temp\\pip-build-ggf9qvw1\\tesseract-ocr\\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\af\AppData\Local\Temp\pip-tcjuee8m-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
file tesseract_ocr.py (for module tesseract_ocr) not found
file tesseract_ocr.py (for module tesseract_ocr) not found
running build_ext
building 'tesseract_ocr' extension
creating build
creating build\temp.win-amd64-3.4
creating build\temp.win-amd64-3.4\Release
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\x86_amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\python34\include -Ic:\python34\include /Tptesseract_ocr.cpp /Fobuild\temp.win-amd64-3.4\Release\tesseract_ocr.obj
tesseract_ocr.cpp
tesseract_ocr.cpp(463) : fatal error C1083: Cannot open include file: 'leptonica/allheaders.h': No such file or directory
error: command 'c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\af\\AppData\\Local\\Temp\\pip-build-ggf9qvw1\\tesseract-ocr\\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\af\AppData\Local\Temp\pip-tcjuee8m-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\af\AppData\Local\Temp\pip-build-ggf9qvw1\tesseract-ocr\
consider using pytesseract, worked for me on python 3.6: pip install pytesseract
If you encounter problems installing it directly by running the above command, try this link :
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Use the "find" tool to find pytesseract and in the directory where its downloaded, hold shift and right click, youll get an option to open a command window there and run:
pip install "filename"
You could also try downloading tesseract-ocr from the link above and perform the installation offline like i just explained.
Never quite figured out why, but some installations that failed worked when dowloaded. Hope that helps.
The fix for this issue is on the Compiling Page of tesseract-ocr
sudo apt-get install libleptonica-dev
I can tell you that this fixed the issue on a Raspberry Pi (Jessie and Stretch) and Debian (8 and 9)

Could not find function xmlCheckVersion in library libxml2 during Scrapy install

I've been looking through endless forums trying to solve this and I still haven't found an answer that works. I'm new to windows and I'm trying to set things up as I have them on my Mac but the Command Line is presented challenges (what's the equivalent to sudo?) eg, on mac I would type 'sudo pip install scrapy', what's the equivalent on windows? I'm getting this error below and I cannot seem to find my way around it. Any thoughts greatly appreciated.
C:\Users\kenma\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc\lxml\includes -Ic:\python27\include -Ic:\python27\PC /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win32-2.7\Release\src\lxml\lxml.etree.obj -w
cl : Command line warning D9025 : overriding '/W3' with '/w'
lxml.etree.c
src\lxml\includes\etree_defs.h(14) : fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
Compile failed: command 'C:\\Users\\kenma\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
creating users
creating users\kenma
creating users\kenma\appdata
creating users\kenma\appdata\local
creating users\kenma\appdata\local\temp
C:\Users\kenma\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I/usr/include/libxml2 /Tcc:\users\kenma\appdata\local\temp\xmlXPathInitdw65bp.c /Fousers\kenma\appdata\local\temp\xmlXPathInitdw65bp.obj
xmlXPathInitdw65bp.c
c:\users\kenma\appdata\local\temp\xmlXPathInitdw65bp.c(1) : fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'C:\\Users\\kenma\\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\\kenma\\appdata\\local\\temp\\pip-build-c6lrhk\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\kenma\appdata\local\temp\pip-vhli1l-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\kenma\appdata\local\temp\pip-build-c6lrhk\lxml\
This seems to be related to lxml installation which is a scrapy dependency.
The official documentation page has some solutions but it recommends to use unofficial binaries for windows operating system which can be found here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

Windows Python2.7 mysqldb installation error

I'm trying to install mysqldb for Python.
I'm running "pip install mysql-python"
and I keep getting this error:
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'fi
nal',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 /Fobui
ld\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 (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
----------------------------------------
Failed building wheel for mysql-python
Failed to build mysql-python
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\scott~1.sco\appdata\local\temp\pip-bu
ild-nja4gr\mysql-python\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install -
-record c:\users\scott~1.sco\appdata\local\temp\pip-5htk1y-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
running build_ext
building '_mysql' extension
C:\Program Files (x86)\Common Files\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_mysql.c /Fob
uild\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 (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
----------------------------------------
Command "c:\python27\python.exe -c "import setuptools, tokenize;file='c:\users\scott~1.sco\appdata\local\temp\pip-build-nja4gr\mysql-python
\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\scott~1
.sco\appdata\local\temp\pip-5htk1y-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\scott
~1.sco\appdata\local\temp\pip-build-nja4gr\mysql-python
Can anyone tell me whats the problem?
Download the pre-compiled whl file for mysql-python from from Christophe Gohlke’s Library of pre-compiled python packages for windows from the below location.
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
Now got to directory where you downloaded that file and open command prompt there.
Now run below command pip install xxx.whl
Best Luck !!
You can try...
pip install mysqlclient==1.3.4
It worked for me.
If the above command doesn't work try this...
pip install --only-binary :all: mysqlclient
both worked for me.
I got a same error.
I solved it by install mysql-connector
You can get a pre-compiled version from Christophe Gohlke’s Library of pre-compiled python packages for windows. Specifically, you can find the MySQL_python package here
Other alternatives would be to use a python distribution that comes with many packages pre-compiled and available for easy installation. Two examples are:
Anaconda Python Distribution
Enthought Canopy Python Distribution
You are missing Visual Studio C++ from your system or the correct environment for VS is not set properly based on the error in your question: "error: command 'C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2"
Please check if you have C++ compiler installed at "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe". If you do not have this installed it is available from Microsoft here: python27 Compiler
If you have VS installed try running the pip install from visual studio command prompt ,which generally would have all the environment created or try to run vcvarsall.bat from "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\" folder
Simply go to the site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
and download mysqlclient wheel file according to your python version and operating system bit specification, then install the downloaded file with typing
pip install downloaded_whl_file_name
Finally install mysqldb with command:
pip install flask-mysqldb
In my case I had to install mysql-connector with the same bitness as my python.
So although I run 64bit windows 10, I have 32bit python 2.7 installed so I had to install 32bit mysql-connector from here
to overcome the error.
The following action, mentioned above by zio, has solved my problem:
You can get a pre-compiled version from Christophe Gohlke’s Library of pre-compiled python packages for windows. Specifically, you can find the MySQL_python package here.
After get the file, install it using pip install.

Resources