Running PyCharm project from command line

If you are running your script from the main_dir, that means when running your Python command, your relative reference is main_dir. So your imports are with respect to main_dir being your root.

This means if we take your script1 for example, your import should look like this:

from other_dir.script2 import *

Chances are your PyCharm project root is actually set to run from

project/

Which is why your references work within PyCharm.

What I suggest you do is, if your server is supposed to run within main_dir then you should re-configure PyCharm so that its execution root is the same in order to remove this confusion.