-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imitate Visual C++ with MinGW or other C++ compilers (for Python packages based on Visual C++) #100764
Comments
This is issue tracker for Visual Studio Code editor, not Microsoft Visual Studio (year). Are you sure that this issue related to Visual Studio Code? |
yes, I refer to Visual Studio Code here. I also wondered about it, but you have to install Microsoft Visual C++ in order to have C++ available for a lot of packages in Python which do not accept any other C++ compiler, and now the question is if Visual Studio Code could give a smart and lightweight alternative to this quite clumpsy approach. (Not the right comparison, but the GB disk size goes into the same direction: For Python to work in Visual Studio Code, you can also just install Python instead of installing 4 GB Anaconda ;) I just trust vscode to be smarter and change things here faster than the Microsoft Visual Studio approach which I do not even need to change, as there, the 4 GB are probably needed. |
@lorenzznerol the VS Code core editor is not the right place for this. It is either the CPP extension or better the Python extension. Please open issues against these extensions. |
######################################################################
This is a full copy of https://stackoverflow.com/questions/62149329/imitate-visual-c-with-mingw-or-other-c-compilers-for-python-packages-based
With an interesting comment from @david Macek
The C++ ABIs (possibly headers even) of GCC and MSVC are just incompatible. You might have some luck using Clang, but I don't guarantee anything. /// If you're concerned about disk space, you might try installing the requisites and then stripping the parts irrelevant to Python packages. There might even be a way to make something of a portable MSVC toolchain, but don't distribute it (I believe it's not allowed in the license).
######################################################################
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 https://stackoverflow.com/questions/29846087/microsoft-visual-c-14-0-is-required-unable-to-find-vcvarsall-bat/51087608#51087608
The error that I get when I install a package that needs MS Visual C++ as an example, installing
pip install 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: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 compilerC:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\c++.exe
might already solve it?The text was updated successfully, but these errors were encountered: