I have the following project structure (using python 3.6):
Project
| scripts
| | module.py
| tests
| | test.py
module.py
contains a class named Class1
.
test.py
has the following code:
from .. scripts.module.py import Class1
However, when I run test.py, I get the following error:
ValueError: attempted relative import beyond top-level package
How do I fix this? Why is the relative import not working?
This post is probably going to be marked as a duplicate, but I either cannot understand the posts that I have seen so far, or the posts do not reflect my situation.
Edit:
I looked at some python Github repositories, and they in their test code, they all do something like import scripts.module
. How does this work?? Do I need an additional file to be able to connect my project like this?
Here are the Github repositories that I looked at. What I am talking about is located in the tests folder: https://github.com/AtsushiSakai/PythonRobotics and https://github.com/nbedos/termtosvg.