Create a PyCharm configuration that runs a module a la "python -m foo"

pycharm, python

Solution

In 2018.1 it is finally possible to specify the module name instead of the script path in the UI. There is a dropdown for changing it, to the left of the input field.

Problem

My python entrypoint needs to be run as a module (not a script), as in: ``` python -m foo.bar ``` The following does not work (and is not supposed to): ``` python foo/bar.py ``` How can I create a run confirguration in pycharm that runs my code using the first invokation above?

Original source