I have a problem with my Python project. My project parses different recipe websites for each recipe and writes the recipe data to a text file.
My Problem: I cannot import a python file/module that resides in the parent directory. This file contains generic functions that parse webpages. I get an error when I do so: "ValueError: Attempted relative import in non-package"
My solution: I dont know what my solution is? I am thinking I either need to find a way to import a file from the parent directory or to change my project architecture so every domain parsing script sits in the same directory
Project Architecture:
Test Folder:
__init__.py
UtilityFunctions.py # the file I am importing
PerformAllIndexing.py
all_recipes:
__init__.py
index.py # imports ../UtilityFunctions.py
simply_recipes:
__init__.py
index.py # imports ../UtilityFunctions.py
Each subdirectory contains a file called index.py that can extract recipe name, ingredients and directions for a specific website and writes it to a text file.
I encourage you to download my project to get a detailed understanding of my problem: http://www.mediafire.com/?ynup22oe8ofam21
Can you tell me what I can do to import a python module from a parent directory or how I can change my project architecture to make this work without having repeating code(the code residing in UtilityFunctions.py)?