title: Installing Twisted for Python using pip: error: Microsoft Visual Studio failed with exit status 2
body: <p>When I try to install the python package Twisted on my windows 10 machine running python3.7, I'm unable to build a Wheel from the .tarz file and I eventually get the following output:</p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DWIN32=1 -Ic:\users\dario\appdata\local\programs\python\python37-32\include -Ic:\users\dario\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\include" "-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:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\include" "-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:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tcsrc/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c /Fobuild\temp.win32-3.7\Release\src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.obj
  iocpsupport.c
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(1933): warning C4047: '=': '__pyx_t_11iocpsupport_HANDLE' differs in levels of indirection from 'HANDLE'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(2077): warning C4022: 'CreateIoCompletionPort': pointer mismatch for actual parameter 1
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(2077): warning C4022: 'CreateIoCompletionPort': pointer mismatch for actual parameter 2
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(2077): warning C4047: '=': '__pyx_t_11iocpsupport_HANDLE' differs in levels of indirection from 'HANDLE'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(2192): warning C4022: 'GetQueuedCompletionStatus': pointer mismatch for actual parameter 1
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(2537): warning C4022: 'PostQueuedCompletionStatus': pointer mismatch for actual parameter 1
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(2648): warning C4022: 'CloseHandle': pointer mismatch for actual parameter 1
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7194): warning C4020: 'function through pointer': too many actual parameters
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7637): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7638): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7639): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7640): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7641): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7642): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7664): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7665): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7666): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7667): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7668): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7669): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7688): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7689): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7690): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7697): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7698): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7699): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7700): error C2039: 'exc_type': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7701): error C2039: 'exc_value': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  src/twisted/internet/iocpreactor/iocpsupport/iocpsupport.c(7702): error C2039: 'exc_traceback': is not a member of '_ts'
  c:\users\dario\appdata\local\programs\python\python37-32\include\pystate.h(209): note: see declaration of '_ts'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
  
  ----------------------------------------
  Command "c:\users\dario\appdata\local\programs\python\python37-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\dario\\AppData\\Local\\Temp\\pip-install-3p6tzbh6\\Twisted\\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\dario\AppData\Local\Temp\pip-record-t02tl1qo\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\dario\AppData\Local\Temp\pip-install-3p6tzbh6\Twisted\
  </code></pre>
  
  <p>I've tried the following things to resolve this issue:</p>
  
  <ul>
  <li>Updating Visual Studio build tools 2017</li>
  <li>Updating pip and setuptools</li>
  <li>Installing Windows 10 SDK in Visual studio build tools 2017</li>
  <li>running pip from administrator command prompt</li>
  <li>running pip from Visual Studio x64 Native Tools Command Prompt</li>
  <li>Installing a wheel from this site:<a href="https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted" rel="noreferrer">https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted</a>
  which does work but then when I run Scrapy it seems the twisted is an outdated version and there's syntax error with python 3.7</li>
  </ul>