Distutils - Where Am I going wrong?
Posted
by RJBrady
on Stack Overflow
See other posts from Stack Overflow
or by RJBrady
Published on 2010-04-28T16:46:10Z
Indexed on
2010/04/28
16:53 UTC
Read the original article
Hit count: 435
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?
© Stack Overflow or respective owner