I’ve stumbled across this annoying error when trying to setup Cython working environment. Here are a couple of good guides: one, two. Everything went fine until I tried to compile the Cython code with
python setup.py build_ext --inplace
Then I got this nasty error:
C:\Users\irmsc\anaconda3\envs\backtesting\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
This is definitely something to do with the Microsoft Visual Studio compatibility. There are some useful advices here and there on the internet like here on StackOverflow where people mostly recommend making sure you install latest Build Tools and Windows 10 SDK via the Visual Studio installer. And a bunch of other things that I tried to no avail.
Of course I could’ve spend a couple more days trying to find the “orthodox” solution but I decided to give a shot to the alternative approaches which can be found over here. It gave Anaconda a try, a second chance actually. Here’s the complete guide.
1: Issue solved by installing Anaconda for Windows 10
2: install cython by running conda install -c anaconda cython in Anaconda prompt
3: go in C:\Users\Utilisateur\Anaconda3\Lib\distutils or wherever your distutils library is the create a distutils.cfg file (by using the notepad) and put
[build] compiler=mingw32
or even
[build] compiler=mingw64
4: get the latest version of Mingw-w64 (not just Mingw which support just 32 bits) at https://sourceforge.net/projects/mingw-w64/files/ and install it
5: add C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin to your Path here is a link on how to do that on windows 10: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/
6: install libpython and m2w64-toolchain in your anaconda envirement by running conda install -c anaconda libpython and conda install -c msys2 m2w64-toolchain It come from these webpage https://python-at-risoe.pages.windenergy.dtu.dk/compiling-on-windows/common_errors.html and should correct the corresponding errors
So now if you run “python setup.py build_ext –inplace” you can see there’s no more error. The nasty “Cannot open include file ‘io.h’ No such file or directory error command failed with exit code 2” – has been fixed!
Hope this helps!