Consider the following folder structure:
main
|
|- misc/helpers.py
|
|- src/script.py
I have a python script located in main/src/
that calls another script containing helper functions located in main/misc/
. This path is added to the sys.path
variable at the top of script.py
. Importantly, modules are loaded in script.py
and not within the helper functions.
The issue is that any function in helpers.py
that depends on a module fails with a NameError
and yells that it cannot find the module. Traceback image is included. For example, one function requires Pandas, which is imported as pd
at the top of script.py
. I get the error NameError: name 'pd' is not defined'
. I'm trying to understand the logic of my mistake and find a solution.