0

It's my firs time trying to create and upload my own package. Here it is -> https://pypi.org/project/testeroozz/0.2/#files

The problem is that when I import testeroozz and then run dir(testerooz) on it - I don't see either of: sum_module (the file holding the class), Summation (the class) or great_summation (the method). And so naturally I can't use either of those and get errors of the form:

AttributeError: module 'testeroozz' has no attribute 'sum_module'
AttributeError: module 'testeroozz' has no attribute 'Summation'
AttributeError: module 'testeroozz' has no attribute 'great_summation'

What am I doing wrong?

ilmoi
  • 1,994
  • 2
  • 21
  • 45

1 Answers1

1

Import the classes and functions that you want to access in your __init__.py file which is in testeroozz package.

Your __init__.py file is currently empty.

It should be:

__init__.py

from testeroozz.sum_module import Summation

You can refer to this article to learn more on publishing your Python project to PyPI.

Saimon
  • 407
  • 2
  • 11
  • This worked, thanks. I do want to ask though - I've seen a ton of posts about updating $PYTHONPATH instead of using __init__.py, and I just couldn't get that approach to work. Is there a chance it's depreciated or something? Eg I can't get any of this advice to work, if I treat file as local -> https://stackoverflow.com/questions/4383571/importing-files-from-different-folder?rq=1 – ilmoi Mar 30 '20 at 18:37