Wing Tips: Using "python -m" in Wing Python IDE

Feb 18, 2020

Let's take a look at how Wing can be configured to debug modules that need to be launched with python -m. This command line option for Python allows searching the Python Path for the name of a module or package, and then loading and executing it. This capability was introduced way back in Python 2.4, and then extended in Python 2.5 through PEP 338 . However, it only came into widespread use relatively recently, for example to launch venv, black, or other command line tools that are shipped as Python packages.

Launching Modules

To configure Wing to launch a module by name with python -m, create a Named Entry Point from the Debug menu, select Named Module, and enter the module or package name and any run arguments:


The above is equivalent to this command line:

python -m mymodule one two

The named entry point can be set as the main entry point for your project under the Debug/Execute tab of Project Properties, from the Project menu:


Or it can be launched from the Debug > Debug Named Entry Point menu or by assigning a key binding to it in the named entry point manager dialog.

Launching Packages

Packages can also be launched in this way, if they include a file named to define the package's main entry point:


Setting Python Path

Whether launching a module or package, the name has to be found on the Python Path that you've configured for your project. If Wing fails to find the module, add its parent directory to Python Path under the Environment tab in Project Properties:


That's it for now! We'll be back soon with more Wing Tips for Wing Python IDE.

As always, please don't hesitate to email if you run into problems or have any questions.

Share this article: