I have a pretty simple Python3 project with this folder structure:
➜ (venv:evernote) evernote_bear_project git:(master) ✗ tree
.
├── README.md
├── bear2evernote
│ ├── static
│ └── templates
├── config
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── manage.py
├── sample
│ ├── EDAMTest.py <--- This here imports from `util.files`
│ └── enlogo.png
└── util
├── __init__.py
├── files.py
└── test_files.py
Now I try to import from util.files
in sample/EDAMTest.py
but I get an error message:
$ cd sample
$ python EDAMTest.py
Traceback (most recent call last):
File "EDAMTest.py", line 18, in <module>
from ..util.files import *
ValueError: attempted relative import beyond top-level package
The import statement in EDAMTest.py
is this line:
from ..util.files import *
There are many articles about Python imports like this, but I still can't resolve it.
The Definitive Guide to Python import Statements
This SO post did't help either:
How to resolve “ValueError: attempted relative import beyond top-level package”
EDIT: If I run the script from the root folder, then I get the same error:
➜ (venv:evernote) evernote_bear_project git:(master) ✗ python sample/EDAMTest.py
Traceback (most recent call last):
File "sample/EDAMTest.py", line 18, in <module>
from ..util.files import *
ValueError: attempted relative import beyond top-level package