Relative import in Python 3 is not working
问题 I have the following directory: mydirectory ├── __init__.py ├── file1.py └── file2.py I have a function f defined in file1.py. If, in file2.py, I do from .file1 import f I get the following error: SystemError: Parent module '' not loaded, cannot perform relative import Why? And how to make it work? 回答1: since file1 and file2 are in the same directory, you don't even need to have an __init__.py file. If you're going to be scaling up, then leave it there. To import something in a file in the