2

I already took a look at this solution Importing classes from different files in a subdirectory , however it's still not working for me.

I have my __init__.py file where I make the import:

from api.get_channel_list import GetChannelList 

but I get the following error when I try to run my app:

from api.get_channel_list.py import GetChannelList
ImportError: No module named get_channel_list.py

The directory is structured this way:


api
    --get_channel_list.py
static
templates
__init__.py

where api, static, and templates are folders. Any idea what I might be doing wrong? I'm very new to python since like 2 days ago. Any pointers towards a solution will be appreciated.

CodeTrooper
  • 1,890
  • 6
  • 32
  • 54
  • Forgot to mention that, there's an __init__.py ont he api directory. – CodeTrooper Aug 14 '17 at 01:54
  • It should be `from api.get_channel_list import GetChannelList` don't need to put the `.py` part – Himal Aug 14 '17 at 01:55
  • if you put ```__init__.py``` on ```api``` directory, you should import it. And just mention, you can only do ```from api.get_channel_list import GetChannelLis``` on code file in the parent directory of ```api``` – wllbll Aug 14 '17 at 02:00
  • Which version of Python?? Try adding a dot - `from .api.get_channel_list import GetChannelList ` – wwii Aug 14 '17 at 03:14

0 Answers0