arevilla009
arevilla009

Reputation: 453

Issues making import in python

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:

enter image description here

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

enter image description here

Thanks for reading.

Upvotes: 0

Views: 45

Answers (1)

Jay Patel
Jay Patel

Reputation: 2451

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.

Upvotes: 1

Related Questions