I'm starting a project that is broken up into multiple packages and files. The problem I quickly encountered is that imports that work when run internally from PyCharm fail when run from a command line. Heres my Current Directory
The contents of File C:
print("File C imported")
The contents of File B:
print("File B imported")
class ClassB:
def __init__(self):
print("Class B made")
The contents of File A:
import src.packageB.fileB as B
import packageC.fileC
B.ClassB()
print("packageA ran")
When I push the play button in PyCharm, all the different modules import and it prints:
File B imported
File C imported
Class B made
packageA ran
When fileA is ran from a command line, the error is thrown saying "No module name src". I've tried running fileA.py from "PackageTest", "src", and "packageA", but changing the directory from where python runs doesn't seem to make a difference.
I'm sure I don't understand the fundamental problem of why this is occurring. I'd really like to understand so when this project becomes much more complex and deep, I can solve import problems just like this. I appreciate the help!