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

后端 未结 5 1192
长情又很酷
长情又很酷 2020-12-07 20:38

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

5条回答
  •  遥遥无期
    2020-12-07 21:14

    In PyCharm 2016 specifying -m without a script path doesn't work, as they use a wrapper script that doesn't accept the -m argument.

    Here's my solution, which works for run & debug configurations: https://github.com/amnong/misc/tree/master/pycharm_runner

    Edit: I just read J. R. Petrus's comment, and my solution is very similar. BTW I also tried to support proper entry points using pkg_resources, but for some reason pkg_resources.load_entry_point() could not find my project's distribution...

提交回复
热议问题