python -m flag
I was testing one of the Python scripts in a custom library by running python graphutils/plot.py one level up from the folder. It threw an error: ImportError: attempted relative import with no known parent package.
Then I ran python -m graphutils.plot to test the .py script in that folder, and it works! Instead of specifying the path to your Python script, you can run a script with dot notation if you are not in the script folder directory.
When you have a Python script that comes with this line if __name__ == “__main__”: and you run the script with the -m flag afterward, it will import the relevant module or package (in this case, graphutils), then execute the stuff after that line.
In the command line, the -m flag allows code execution via the module name rather than the filename when the script contains relative imports without installing them.