1

I'm not sure why it won't work, it may be an issue that you can't work around, but I would just like to know why it won't work. I am sorry if I waste your time, or didn't ask the question properly, I'm 16 and new to Python kind of.

in main.py

from day_one import day_one_def

in day_one.py

from main import main_home_window

error message

ImportError: cannot import name 'day_one'

1 Answers1

1

It looks like you have a circular import: main imports from day_one and day_one imports from main. This isn't really how python is supposed to work. You should create linear dependencies, where the top module only relies on the ones below it, which only rely on the ones below them, etc.

Aya Maguire
  • 131
  • 7
  • Yeah, that's what I thought too, I'm new so I wasn't sure if I was just doing something wrong. Thank you –  Dec 09 '18 at 18:55
  • This may also be another dumb question, but even though it goes against what you said, I ask for user input in day_one.py, and I was to send it back to the first file. Should I not attempt this? –  Dec 09 '18 at 18:59
  • No, it's normal for main to import from other modules and use them. What you shouldn't do is "import main" from the module main relies on. So, in "day_one.py" you need to remove the import. Whatever "day_one.py" is doing with "main_home_window" seems like it should be done in main instead. – Aya Maguire Dec 09 '18 at 19:24
  • Okay, yeah that does make more sense, I do not know what I was even doing. Thank you, kind of a realization. It was a big help, really. I'm not as dumb as I sound, I promise lol. Thank you, have a great day. –  Dec 09 '18 at 19:33