Meaning of python -m flag

2020-02-09 01:28发布

What does -m in python -m pip install <package> mean ? or while upgrading pip using python -m pip install --upgrade pip.

3条回答
放荡不羁爱自由
2楼-- · 2020-02-09 02:10

From Python Docs

The argument is a module name, you must not give a file extension (.py). The module-name should be a valid Python module name, but the implementation may not always enforce this (e.g. it may allow you to use a name that includes a hyphen).

Package names are also permitted. When a package name is supplied instead of a normal module, the interpreter will execute .main as the main module. This behaviour is deliberately similar to the handling of directories and zipfiles that are passed to the interpreter as the script argument.

查看更多
孤傲高冷的网名
3楼-- · 2020-02-09 02:15

The -m stands for module-name.

From Command line and environment:

python [-bBdEhiIOqsSuvVWx?] [-c command | -m module-name | script | - ] [args]

查看更多
混吃等死
4楼-- · 2020-02-09 02:20

If you type python --help

You get

// More flags above
-m mod : run library module as a script (terminates option list)
// and more flags below

A great many things in a terminal will show you how to use it if you either use command --help or man command

查看更多
登录 后发表回答