Cython- Cannot open include file: 'io.h': No such file or directory

In case anyone finds this thread and is looking for a quicker solution than reinstalling VS and/or Anaconda - I was able to get past this same error by defining the environment variable INCLUDE pointing to the location of io.h - allowing the VS compiler to locate the header.

In my setup, using VS2015, the change to using the Universal CRT means the location of io.h is C:\Program Files (x86)\Windows Kits\10\Include\<version>\ucrt. For different versions/environments the location of io.h may differ.


Download visual studio build tools and install

  1. Visual C++ Build tools core features.
  2. VC++ 2017 v141 toolset (x86,x64)
  3. Visual C++ 2017 Redistributable Update
  4. Windows 10 SDK (10.0.16299.0) for Desktop C++

enter image description here

Justin Kirk

Microsoft doesn't make any effort to make console development steps obvious anymore. Visual Studio has long been packaged with some batch files to establish environment variables. When the C++ CLI development options are selected in VS2015/2017, there are one or more shortcuts added to the start menu to execute these batch files.

For VS 2017 the various batch files all call:

C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\vcvarsall.bat

with specific parameters.

Rather than setting a System or User Environment Variable, it would be better to call the specific batch file to meet your build needs.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat


C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat

One thing to bear in mind with Python/Ruby/etc, scripts will often need to elevate the execution shell to Administrator role in order to install packages. If you execute the batch file in a non-Administrator shell, and the package installation requires elevation it will spawn a subshell which will not have the environment variables. Therefore, you should run the batch file in an Administrator shell before calling the package manager or script.

I stumbled upon the same problem - with very similar configuration to yours (only difference: VS 2015 Pro). After a few weeks on just having to download wheels from other people (e.g. I finally found a solution which works for me.

There are 2 problems. Problem 1 - you need to use "Developer Command Prompt" - sometimes there is such a program in Start Menu, then you just use it.

(BTW, for others: Python 3.5 needs VS2015, not any other version. Community edition is OK)

If not, you can use the following snippet (in command line):


or even:

where cl >nul 2>nul || "%VS140COMNTOOLS%vsvars32.bat"

(i have it in a batch file to run my build environment)

(If you dont have the %VS140COMNTOOLS% variable, then maybe you just installed the VS and you need e.g. to restart, so that new environment variables become visible).

Now you will get the error:

c:\program files\anaconda3\include\pyconfig.h(68): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

(as in your edited answer)

So now run:

set INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt

OK, now you will get the error:

LINK : fatal error LNK1104: cannot open file 'ucrt.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1104

What now? You need to add library dirs:

set LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64

No errors this time:

> dir
05/16/2017  11:33 AM            69,240 hello.c
05/16/2017  11:47 AM            15,872 hello.cp35-win_amd64.pyd
05/16/2017  11:32 AM                17 hello.pyx

TL;DR - the whole thing:

where cl >nul 2>nul || "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" amd64
set INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
set LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64
python build_ext --inplace

I had the same problem, solved it by installing Windows 10 SDK.

I received the same error when trying to install pyshark and I resolved this issue by running pip install pyshark in Developer Command Prompty for VS 2017 and making sure I had VC++ tools installed.

Add windows 10 sdk in your environment path.

C:\Program Files (x86)\Windows Kits\10\Include\\ucrt

  1. apply the changes.
  2. open a new command prompt with administrator rights.

the error should be removed.

If anyone is running into this error while trying to install in Git Bash (I imagine this would also work for any Bash shell running on Windows using the Visual Studio compiler), then you can do the following:

INCLUDE="C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/ucrt/;C:/Program Files (x86)/Windows Kits/10/Include/10.0.17763.0/shared/" \
> LIB="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17763.0/ucrt/x64;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17763.0/um/x64" \
> PATH=$PATH:/c/Program\ Files\ \(x86\)/Windows\ Kits/10/bin/10.0.17763.0/x64 \
> python -m pip install <package>

For different versions of Windows and Visual Studio these paths may be slightly different. The best way to get them is when an error is thrown, search for the file with

find /c/Program\ Files\ \(x86\)/ -name <name_of_error_causing_file>

This is because Cython require libraries provided by Windows SDK. To fix this, do the following:

  1. Install Build Tools for Visual Studio 2019. Download from here. Build Tools for Visual Studio 2019 download page
  2. Run VS Build Tools setup files (vs_buildtools.exe). Choose:
    • MSVC build tools (MSVC v142 - VS 2019 C++ x64/x86 build tools)
    • Windows 10 SDK Build Tools for Visual Studio 2019 installation
  3. Install VS Build Tools, it will require around 3 GB of space.
  4. From Start Menu, run Developer Command Prompt for VS 2019. Developer Command Prompt for VS 2019
  5. Go to your Cython development directory and then run: python build_ext --inplace

Hopefully this will fix your problem.


It can be solved by adding include dirs and library dirs as follow:

set INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\onecore\x64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64
set LIB=E:\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\onecore\x64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64

and if then you are now getting a problem: link error can run with rc.exe; you also need copy rc.exe and rc.dll (x64) to the dir which is the same with the running link.exe