Is there a way to use MinGW as a substitute of MS Visual C++? A lot of Python packages need VS C++ to be installed: 4.5 GB of disk space! MinGW takes only 450 MB and reaches the same aim to compile C/C++.
I am using Visual Studio Code, and I try to avoid the Microsoft Visual C++ installation that is proposed here under 3) --> You can also install just the C++ Build Tools: https://code.visualstudio.com/docs/cpp/config-msvc/#_prerequisites
Perhaps there is just a trick needed to imitate MS Visual C++ with MinGW, so that the Python packages directly find the MinGW compiler as if it were MS Visual C++? Perhaps adding symlinks to the lib directory and adding some system variable path?
My question is strongly linked with Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
The error that I get when I install a package that needs MS Visual C++ as an example, installing pip install dtaidistance
:
creating build\temp.win-amd64-3.7\Release\dtaidistance
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Admin\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\Admin\Anaconda3\include -IC:\Users\Admin\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" /Tcdtaidistance/dtw_c.c /Fobuild\temp.win-amd64-3.7\Release\dtaidistance/dtw_c.obj /openmp /Ox /fp:fast /favor:INTEL64 /Og
cl : Befehlszeile warning D9035 : Die Option "Og" ist veraltet und wird in einer der n„chsten Versionen entfernt.
dtw_c.c
C:\Users\Admin\Anaconda3\include\pyconfig.h(59): fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "io.h": No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for dtaidistance
Running setup.py clean for dtaidistance
Failed to build dtaidistance
Installing collected packages: dtaidistance
Running setup.py install for dtaidistance ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Admin\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-5lb8uekg\\dtaidistance\\setup.py'"'"'; __file__='"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-5lb8uekg\\dtaidistance\\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\Admin\AppData\Local\Temp\pip-record-dzfe2cwr\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\Admin\AppData\Local\Temp\pip-install-5lb8uekg\dtaidistance\
After installing only MSVC (1.8 GB) - only that, as a test to see if that is already all I need:
We see that the installation still fails, but the error changes slightly, as at least ERROR: Failed building wheel for dtaidistance
has disappeared now, see the following screenshot:
creating build\temp.win-amd64-3.7\Release\dtaidistance
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Admin\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\Admin\Anaconda3\include -IC:\Users\Admin\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" /Tcdtaidistance/dtw_c.c /Fobuild\temp.win-amd64-3.7\Release\dtaidistance/dtw_c.obj /openmp /Ox /fp:fast /favor:INTEL64 /Og
cl : Befehlszeile warning D9035 : Die Option "Og" ist veraltet und wird in einer der n„chsten Versionen entfernt.
dtw_c.c
C:\Users\Admin\Anaconda3\include\pyconfig.h(59): fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "io.h": No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Admin\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-jr44cxi8\\dtaidistance\\setup.py'"'"'; __file__='"'"'C:\\Users\\Admin\\AppData\\Local\\Temp\\pip-install-jr44cxi8\\dtaidistance\\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\Admin\AppData\Local\Temp\pip-record-t_8xl3_a\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
After installing the other 4 checkboxes directly below the MSVC checkbox in the screenshot of MS Visual++ above, I could install the package.
Perhaps changing the assigned C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe
somewhere in the python settings to MinGW gcc compiler C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\c++.exe
might already solve it?