Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 745963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:38:39+00:00 2026-05-14T09:38:39+00:00

I wanted to learn how to create python packages, so I visited http://docs.python.org/distutils/index.html .

  • 0

I wanted to learn how to create python packages, so I visited http://docs.python.org/distutils/index.html.

For this exercise I’m using Python 2.6.2 on Windows XP.

I followed along with the simple example and created a small test project:

person/

    setup.py

    person/
       __init__.py
       person.py

My person.py file is simple:

class Person(object):   
    def __init__(self, name="", age=0):
        self.name = name
        self.age = age

    def sound_off(self):
        print "%s %d" % (self.name, self.age)

And my setup.py file is:

from distutils.core import setup
setup(name='person',
    version='0.1',
    packages=['person'],
    )

I ran python setup.py sdist and it created MANIFEST, dist/ and build/. Next I ran python setup.py install and it installed it to my site packages directory.

I run the python console and can import the person module, but I cannot import the Person class.

>>>import person
>>>from person import Person
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name Person

I checked the files added to site-packages and checked the sys.path in the console, they seem ok. Why can’t I import the Person class. Where did I go wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T09:38:39+00:00Added an answer on May 14, 2026 at 9:38 am
    person/
       __init__.py
       person.py
    

    You’ve got a package called person, and a module inside it called person.person. You defined the class in that module, so to access it you’d have to say:

    import person.person
    p= person.person.Person('Tim', 42)
    

    If you want to put members directly inside the package person, you’d put them in the __init__.py file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to learn Python using some tutorials, and I decided to create
i try to learn scheme and as a test project i wanted to create
I wanted to learn a little about multi threading in .NET and grabbed this
I have some experience in SL/WPF. I always wanted to learn how to create
I am starting to learn c# and wanted to create an actual app which
I am newbie programmer in cocos2D.... I wanted to create the Endless Background using
I wanted to create (or at least learn/know how it is done) application(or configuration?)
I wanted to learn something about Spring and Maven, so I created sample Maven
I wanted to learn some graphics and thereby gaming coding in iPhone. I have
I wanted to learn C, so I decided to start a C project and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.