newbie: cannot import name error

rjberman at rjberman at
Fri Sep 7 15:28:58 CEST 2001

I am brand new to Python, but have been writing Perl scripts for
the last 10 yrs. or so. I want to see how Python compares to Perl
and if it lives up to its hype.

Anyway, I installed Python version "1.6a2 (#1, Jun  1 2000, 13:24:17)
[GCC 2.96 20000306 (experimental)] on sunos5" on Sparc Solaris 8. It
installed fine, and for my first contact with Python I wrote the
requisite "Hello World" script. That too ran fine. Then I got adventurous
and tried to install an extension. That didn't work at all. I narrowed
down the problem as best I could.

Here is my stripped down script:

#!/usr/bin/env python
# To use:
#       python install

import distutils, os, sys, stat
from distutils.core import setup, Extension

The error I get is:

131> python

Traceback (most recent call last):
  File "", line 7, in ?
    from distutils.core import setup, Extension
ImportError: cannot import name Extension

I tried reinstalling distutils just in case that was the problem.
No luck. I grepped through distutils/* and distutils/core/* for
Extension and couldn't find Extension. I have no idea where it
should be anyway. I searched Google and couldn't find this error.
It seems like the module distutils.core is found, just not the
name "Extension".

Can someone help me? I can't believe that on my second encounter
with Python I've already been stumped! This is not a good first
impression. Any help would be appreciated or even pointers to help!

More information about the Python-list mailing list