mAm
mAm

Reputation: 167

Importing module named same as package

I have ran into this so many times. Always struggle and forget. This time I ax. This is python3.

repo/
  setup.py
  abyss/
    __init__.py
    abyss.py
    some.py
# abyss.py

from abyss import some

print(some.x)
# some.py

x = 2

when i run ./abyss/abyss.py I get ImportError: cannot import name 'some' from 'abyss'

Upvotes: 1

Views: 56

Answers (1)

pbacterio
pbacterio

Reputation: 1152

some.py is at the same level that abyss.py, so just using import some works.

Upvotes: 2

Related Questions