I'm new with python and I'm trying to import one module for using some functions but I'm having issues with it. This is my directory:
This is my source path:
/home/adrian/eclipse-workspace/Desarrollos/desarollos_backend_HLC_filters/website_base_filter_2/controllers/generic_functions.py
This is my class inside the file.
class CustomerPortalFilters(CustomerPortal):
def hola(self):
print('que pasa')
From the module website_invoice_filter_2 I need to import the file generic_functions.py from website_base_filter_2.
This is my try, but Eclipse IDE cannot resolve it.
from Desarrollos.desarollos_backend_HLC_filters.website_base_filter_2.controllers.generic_functions import CustomerPortalFilters
Thanks for reading.
1 Answer 1
You need to add __init__.py at the root level in order to use it in the import.
Just create a new empty file named __init__.py and try again. Basically it will tell the interpreter that it is a python directory so that you can use it in other python files.
5 Comments
../website_base_filter_2.controllers.generic_functions
__init__.pyin all directories all the way down to the file you want to import. Could you try to add one in each directory and try again?