python import module from different folder

Viewed 53

I have the following folder structure:

enter image description here

In this process_file.py script I want to be able to import the class process_things.py which is in the classes folder. Tried following method 3 in this blog but it doesn't seem to work: https://blog.finxter.com/python-how-to-import-modules-from-another-folder/

I have noticed that if I put the process_file.py file outside the jobs folder and run from classes import process_file then it works fine, but ideally I really want the file to be in the jobs folder.

1 Answers

did you check sys lib? a quick way like this :

    import sys
    sys.path.append('/path_to_your_project_folder/src/databricks/classes')
    import process_things
Related