Setuptools: DistutilsPlatformError in mingw built Python 2 (msys2)

Created on 2 Aug 2017  路  6Comments  路  Source: pypa/setuptools

Trying to do many things using setuptools in a mingw built Python 2 (For example msys2's mingw-w64-x86_64-python2 fails with this exception:

$ python setup.py build_ext
Traceback (most recent call last):
  File "setup.py", line 1, in <module>
    from setuptools import setup, Extension
  File "mingw64/lib/python2.7/site-packages/setuptools/__init__.py", line 160, in <module>
    monkey.patch_all()
  File "mingw64/lib/python2.7/site-packages/setuptools/monkey.py", line 104, in patch_all
    patch_for_msvc_specialized_compiler()
  File "mingw64/lib/python2.7/site-packages/setuptools/monkey.py", line 156, in patch_for_msvc_specialized_compiler
    msvc = import_module('setuptools.msvc')
  File "mingw64/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "mingw64/lib/python2.7/site-packages/setuptools/msvc.py", line 49, in <module>
    from distutils.msvc9compiler import Reg
  File "mingw64/lib/python2.7/distutils/msvc9compiler.py", line 306, in <module>
    raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
distutils.errors.DistutilsPlatformError: VC 6.0 is not supported by this module

distutils.msvc9compiler doesn't like being imported on mingw built Python, and this hack isn't necessary there.

P.S. I'm going to send a PR.

Most helpful comment

@krzychb A quick workaround would be to allow the function to continue, even without the 'required' compiler.

In your case, in the file C:/msys32/mingw32/lib/python2.7/distutils/msvc9compiler.py remark line 306, and add the pass statement, so that the code looks more or less like the following:

+---[C:/msys32/mingw32/lib/python2.7/distutils/msvc9compiler.py:309]
| 
| # More globals
| VERSION = get_build_version()
| if VERSION < 8.0:
|     pass
| #    raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
| # MACROS = MacroExpander(VERSION)
| 
+---

This probably should do the trick..

All 6 comments

Hi @segevfiner, @jaraco:

I was comforted with similar issue using previous version of setuptools. Seeing it fixed in #1119, I have upgraded my installation of setuptools to the latest version 36.7.0. Unfortunately the issue persists.

krzysztof@Pkrzysztof MINGW32 ~/esp/esp-idf/docs
$ pip install sphinxcontrib.blockdiag
Collecting sphinxcontrib.blockdiag
  Using cached sphinxcontrib_blockdiag-1.5.5-py2.py3-none-any.whl
Requirement already satisfied: Sphinx>=0.6 in c:/msys32/mingw32/lib/python2.7/site-packages (from sphinxcontrib.blockdiag)
Collecting blockdiag>=1.5.0 (from sphinxcontrib.blockdiag)
  Using cached blockdiag-1.5.3-py2.py3-none-any.whl
Requirement already satisfied: alabaster<0.8,>=0.7 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: Jinja2>=2.3 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: snowballstemmer>=1.1 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: babel!=2.0,>=1.3 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: imagesize in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: setuptools in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: Pygments>=2.0 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: typing; python_version < "3.5" in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: colorama>=0.3.5; sys_platform == "win32" in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: docutils>=0.11 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: requests>=2.0.0 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: six>=1.5 in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: sphinxcontrib-websupport in c:/msys32/mingw32/lib/python2.7/site-packages (from Sphinx>=0.6->sphinxcontrib.blockdiag)
Requirement already satisfied: funcparserlib in c:/msys32/mingw32/lib/python2.7/site-packages (from blockdiag>=1.5.0->sphinxcontrib.blockdiag)
Requirement already satisfied: webcolors in c:/msys32/mingw32/lib/python2.7/site-packages (from blockdiag>=1.5.0->sphinxcontrib.blockdiag)
Collecting Pillow (from blockdiag>=1.5.0->sphinxcontrib.blockdiag)
  Using cached Pillow-4.3.0.tar.gz
Exception:
Traceback (most recent call last):
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/commands/install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
    abstract_dist.prep_for_dist()
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/req/req_install.py", line 412, in run_egg_info
    self.setup_py, self.name,
  File "C:/msys32/mingw32/lib/python2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
    import setuptools  # noqa
  File "C:/msys32/mingw32/lib/python2.7/site-packages/setuptools/__init__.py", line 180, in <module>
    monkey.patch_all()
  File "C:/msys32/mingw32/lib/python2.7/site-packages/setuptools/monkey.py", line 104, in patch_all
    patch_for_msvc_specialized_compiler()
  File "C:/msys32/mingw32/lib/python2.7/site-packages/setuptools/monkey.py", line 182, in patch_for_msvc_specialized_compiler
    patch_func(*msvc9('find_vcvarsall'))
  File "C:/msys32/mingw32/lib/python2.7/site-packages/setuptools/monkey.py", line 169, in patch_params
    mod = import_module(mod_name)
  File "C:/msys32/mingw32/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "C:/msys32/mingw32/lib/python2.7/distutils/msvc9compiler.py", line 306, in <module>
    raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
DistutilsPlatformError: VC 6.0 is not supported by this module

Please give me some guidance ow to troubleshoot it.

@krzychb A quick workaround would be to allow the function to continue, even without the 'required' compiler.

In your case, in the file C:/msys32/mingw32/lib/python2.7/distutils/msvc9compiler.py remark line 306, and add the pass statement, so that the code looks more or less like the following:

+---[C:/msys32/mingw32/lib/python2.7/distutils/msvc9compiler.py:309]
| 
| # More globals
| VERSION = get_build_version()
| if VERSION < 8.0:
|     pass
| #    raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
| # MACROS = MacroExpander(VERSION)
| 
+---

This probably should do the trick..

Hi @PeterMosmans,

Thank you for looking into this issue!

In the meantime I have managed to bypass this issue by installing latest pillow with pacman - https://github.com/Alexpux/MINGW-packages/pull/3138, and then running pip install sphinxcontrib.blockdiag again.

This way there was no need to compile anything within the pillow source package.

Thank you @PeterMosmans , the trick works for me

Somehow, over a year later, this is still an issue.
In my case not related to setuptools though - I used python3-pip from mingw64 to install bcrypt.
Same error, same remedy. Thank you @PeterMosmans.

We've patched distutils in MSYS2 to work around this issue in the meantime: https://github.com/msys2/MINGW-packages/commit/8a162525a7d6f4a0ac2724db2e21c96eae1ba33f (importing msvc9compiler doesn't error out anymore now, only using the included code)

Was this page helpful?
0 / 5 - 0 ratings