0

I have an import problem which is probably obvious, but I'm kind of stuck, so I will ask here, maybe you will see it immediately:

files structure:

foobar_package/
    __init__.py
    classes.py
    enums.py

classes.py:

import enums

class Foo:
   ...

I want Foo class to be importable directly from the package: Instead of:

from foobar_package.classes import Foo

I want to be able to write:

from foobar_package import Foo

So I edited my init.py: __init__.py:

from .classes import *

The problem is, when do:

import foobar_package

I get:

  File "foobar_package/__init__.py", line 2, in <module>
    from .classes import *
  File "foobar_package/classes.py", line 4, in <module>
    import enums
ModuleNotFoundError: No module named 'enums'

Any idea?

MKaras
  • 665
  • 7
  • 17

0 Answers0