I have a workspace called "bi-etl". The structure is as follows:
├───bi-etl
│ ├───utils
│ │ ├───file_a.py
│ │ └───file_b.py
│ ├───googlesheet
│ │ ├───parameter_update.py
The parameter_update.py is intended to import file_a.py and file_b.py from the utils folder, which as you can see, is not in the same folder as parameter_update.py which is in the googlesheet folder.
Following the link: Importing files from different folder
I tried the following but none seems to work so far.
Method 1: (Content of parameter_update.py)
#import modules
import pandas as pd
import json
import requests
import urllib.parse as urlparse
from datetime import datetime
import os
import sys
import importlib.util
sys.path.insert(0, '/C:/bi-etl/utils/file_a.py')
sys.path.insert(0, '/C:/bi-etl/utils/file_b.py')
from file_a import logger, report
from file_b import get_env, get_path
returns ModuleNotFoundError: No module named 'file_a'
Trying another method,
based on "from application.app.folder.file import func_name"
(content of parameter_update.py)
#import modules
import pandas as pd
import json
import requests
import urllib.parse as urlparse
from datetime import datetime
import os
import sys
import importlib.util
from bi-etl.utils.file_a import logger
returns
from bi-etl.utils.file_a import logger
^
SyntaxError: invalid syntax