I’m using VS code and a conda venv. I have created a folder called "project" and in the folder I have 3 sub folders "helper", "function", "function2". Now I have a helper_function.py in folder "helper" where I have defined several functions and I want to import them in my function code where I have a main.py.
project/
helper/
__init__.py
helper_function.py
function/
__init__.py
main.py
function2/
__init__.py
I’m always receiving the error:
from helper.helper_function import date_conf
ModuleNotFoundError: No module named 'helper'
I have already created a blank __init__.py
in the helper folder but it’s still the same.
2
Answers
You have at least 3 possibilities:
If you’re using VSCode, the simplest is probably to update your PYTHONPATH in settings, assuming you have a linux terminal:
helper directory must be same level as "main.py" (considering your current working directory is where main.py located).
i suggest you read this to get familiar with relative and absolute imports.