Calling python from command line

Hello, I’ve been tinkering around with python for a while, I’m exploring Flask at the moment but I’ve stumbled upon this on numerous occasions.

I’m running Python 3.10.7

For example when I’m installing packages with pip I have to write:

py -m pip install *package*

but I don’t see it written this way often, mostly people just tell you to run

py pip install *package*

or just 

pip install *package*

but I get an error with either of those…

What’s that -m flag? I can’t seem to find the documentation for it, what does it stand for and what does it do and why it doesn’t work without it?

Any explanation and/or insight will be appreciated <3

1 Like

Try running which pip (are you on Linux?)
And which pip3

Also try py —help or py -h -m

And there is some instructions here that may be good to try

https://packaging.python.org/en/latest/tutorials/installing-packages.html

Also seems that -m is essentially a “module naming” option

1 Like

Sorry I forgot to mention I’m on Windows. I’ve found the answer in py -help (God how come I didn’t thought of running this?!)

-m stands for “run library module as script”

That’s why these don’t work:

py flask run
py pycodestyle main.py

but these do:

py -m flask run
py -m pycodestyle main.py

Thank you for guiding me in the right direction!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.