#18 ImportError DistutilsOptionError on Python 2.7

closed
nobody
None
5
2013-12-31
2010-07-29
Jason R. Coombs
No

With Python 2.7, DistutilsOptionError was removed from distutils.core, though it still officially remains in distutils.errors. This causes comtypes to not install properly. Instead, an error similar to the following is generated:
\comtypes> .\setup.py
Traceback (most recent call last):
File "\comtypes\setup.py", line 42, in <module>
from distutils.core import setup, Command, DistutilsOptionError
ImportError: cannot import name DistutilsOptionError

The following patch fixes the issue:

Index: setup.py

--- setup.py (revision 574)
+++ setup.py (working copy)
@@ -39,7 +39,8 @@
"""
import sys, os
import ctypes
-from distutils.core import setup, Command, DistutilsOptionError
+from distutils.core import setup, Command
+from distutils.errors import DistutilsOptionError

try:
from distutils.command.build_py import build_py_2to3 as build_py

Discussion

  • I'm still getting this error. Is there any reason this hasn't been fixed in trunk?

     
  • Thomas Heller
    Thomas Heller
    2011-04-18

    Fixed with svn rev. 576.

    Sorry for the delay.

     
  • Thomas Heller
    Thomas Heller
    2011-04-18

    • status: open --> closed