I created a new Function App project using Python 3.8 in VS Code on Windows 10. I am trying to import a local module from within the project like this:
import shared_code.my_second_helper_function
So the import works and the code runs when I run the function via 'func start' from the command line at the root of the project. My issue is I get errors when I try to run the debugger. When I hit the debug button in VS Code, I get an error:
Exception has occurred: ModuleNotFoundError 'No module named shared_code' in my_first_function\__init__.py
debug console output:
(.venv) PS C:\Source\Azure-Functions-Python> c:; cd 'C:\Source\Azure-Functions-Python'; & 'C:\Source\Azure-Functions-Python\.venv\Scripts\python.exe' 'c:\Users\myuser\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy\launcher' '55726' '--' 'C:\Source\Azure-Functions-Python\HistorianHttpTrigger\__init__.py'
I'm not sure if this has to do with VS Code or python path or something. Not sure if anyone can create a new function app project in VS Code and setup a shared sibling directory and create a foo.py and try to import and call it from an HttpTrigger
I have a project File structure like this:
<project_root>/
| - .venv/
| - .vscode/
| - my_first_function/
| | - __init__.py
| | - function.json
| | - example.py
| - my_second_function/
| | - __init__.py
| | - function.json
| - shared_code/
| | - __init__.py
| | - my_first_helper_function.py
| | - my_second_helper_function.py
| - tests/
| | - test_my_second_function.py
| - .funcignore
| - host.json
| - local.settings.json
| - requirements.txt