0

This situation may be related to python's configuration. My OS is OSX 10.14.6

Here is my directory tree:

code
|--- main.py
|--- module
     |--- __init__.py
     |--- core.py
     |--- util.py

In main.py

from module import core

In core.py

import util

This works (python2):

python main.py

And this does not:

python3 main.py

Error:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from module import core
  File "/code/module/core.py", line 1, in <module>
    import util
ModuleNotFoundError: No module named 'util'
Ruofeng
  • 2,180
  • 3
  • 14
  • 15

1 Answers1

0

The solution I can give you is replace

import util

with

from . import util

I think this has something to do with python3's Implicit Namespace Packages basically making . it's own module as it were. That's my guess, I haven't found anything in the docs explicitly saying that.

Davenporten
  • 323
  • 2
  • 13