Python relative import in subdirectory

68
July 19, 2021, at 4:00 PM

I have a Python project, which has something like the following structure:

project
|- src
|  |- __init__.py
|  |- package
|  |  |- __init__.py
|  |  |- main.py
|  |  |- settings.py
|  |- tests
|  |  | tests.py

Now my problem is, that I need to access some resources from settings.py in tests.py. I tried using relative imports, which gave me an ImportError: attempted relative import with no known parent package.

from ..package import settings

I was wondering what would be the right way to import such resources? Is my structure completely messed up? I am using Python 3.8 in a Conda environment.

Any help is appreciated, thank you!

READ ALSO
Ability to find certain pages through search

Ability to find certain pages through search

I want to have a search bar that search all the views that are static and supplies search results for example this page here has the function I need: https://cagenixcom/

51
React Router Dynamic Route: Invalid URL

React Router Dynamic Route: Invalid URL

<Route path={"/movie/:id"} component={ResultPage} />

50
Comparing strtotime in PHP [closed]

Comparing strtotime in PHP [closed]

Want to improve this question? Update the question so it's on-topic for Stack Overflow

83
How to use columns in a DataGridView to influence MySQL

How to use columns in a DataGridView to influence MySQL

Currently I'm working on a project where a person can import an excel file (containing stock quantity) into a DataGridView and then export it into a MySQL tableWhen exporting to MySQL, I want to take the stock quantity in the file away from another table in MySQL (like if you were moving...

58