Python Commands

Complete Python commands reference — 73 commands across 4 categories. Quick reference cheat sheet for Windows, Mac & Linux.

Running Code (4)

ShortcutAction
python -c <command>Execute the Python code in command
python -m <module-name>Locate the module using the standard import
python -Read commands from standard input (sys.stdin)
python <script>Execute the Python code contained in script, which must be a filesystem path

Help & Version (5)

ShortcutAction
python -?Print a short description of all command line
python --help-envPrint a short description of Python-specific
python --help-xoptionsPrint a description of implementation-specific -X
python --help-allPrint complete usage information and exit
python -VPrint the Python version number and exit

Interpreter Options (18)

ShortcutAction
python -bIssue a warning when converting bytes or bytearray
python -BIf given, Python won't try to write.pyc files
python --check-hash-based-pycs defaultControl the validation behavior of hash-based.pyc
python -dTurn on parser debugging output (for expert only)
python -EIgnore all PYTHON* environment variables, e.g
python -iEnter interactive mode after execution
python -IRun Python in isolated mode
python -ORemove assert statements and any code conditional
python -OODo -O and also discard docstrings
python -PDon't prepend a potentially unsafe path to sys.path
python -qDon't display the copyright and version messages
python -RTurn on hash randomization
python -sDon't add the user site-packages directory
python -SDisable the import of the module site
python -uForce the stdout and stderr streams to be unbuffered
python -vPrint a message each time a module is initialized
python -xSkip the first line of the source, allowing use
python -XReserved for various implementation-specific options

pip install Options (46)

ShortcutAction
pip install -r <file>Install from the given requirements file
pip install -c <file>Constrain versions using the given constraints file
pip install --build-constraint <file>Constrain build dependencies using the given
pip install --requirements-from-script <file>Install dependencies of the given script file
pip install --no-depsDon't install package dependencies
pip install -e <path/url>Install a project in editable mode (i.e
pip install --dry-runDon't actually install anything, just print what
pip install -t <dir>Install packages into <dir>
pip install --platform <platform>Only use wheels compatible with <platform>
pip install --python-version <python_version>The Python interpreter version to use for wheel
pip install --implementation <implementation>Only use wheels compatible with Python
pip install --abi <abi>Only use wheels compatible with Python abi <abi>
pip install --userInstall to the Python user install directory
pip install --root <dir>Install everything relative to this alternate root
pip install --prefix <dir>Installation prefix where lib, bin and other
pip install --src <dir>Directory to check out editable projects
pip install -UUpgrade all specified packages to the newest
pip install --upgrade-strategy <upgrade_strategy>Determines how dependency upgrading should
pip install --force-reinstallReinstall all packages even if they are already
pip install -IIgnore the installed packages, overwriting them
pip install --ignore-requires-pythonIgnore the Requires-Python information
pip install --no-build-isolationDisable isolation when building a modern source
pip install --check-build-dependenciesCheck the build dependencies
pip install --break-system-packagesAllow pip to modify an EXTERNALLY-MANAGED Python
pip install -C <settings>Configuration settings to be passed to the build
pip install --compileCompile Python source files to bytecode
pip install --no-compileDo not compile Python source files to bytecode
pip install --no-warn-script-locationDo not warn when installing scripts outside PATH
pip install --no-warn-conflictsDo not warn about broken dependencies (environment
pip install --require-hashesRequire a hash to check each requirement against
pip install --progress-bar <progress_bar>Specify whether the progress bar should be used
pip install --root-user-action <root_user_action>Action if pip is run as a root user [warn, ignore]
pip install --report <file>Generate a JSON file describing what pip did
pip install --group <[path:]group>Install a named dependency-group
pip install --no-cleanDon't clean up build directories
pip install -i <url>Base URL of the Python Package Index
pip install --extra-index-url <url>Extra URLs of package indexes to use in addition
pip install --no-indexIgnore package index (only looking at --find-links
pip install -f <url>If a URL or path to an html file, then parse
pip install --uploaded-prior-to <datetime_or_duration>Only consider packages uploaded prior to the given
pip install --preInclude pre-release and development versions
pip install --all-releases <release_control>Allow all release types (including pre-releases)
pip install --only-final <release_control>Only allow final releases (no pre-releases)
pip install --no-binary <format_control>Do not use binary packages
pip install --only-binary <format_control>Do not use source packages
pip install --prefer-binaryPrefer binary packages over source packages, even
📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

Related Shortcut Pages

Anaconda Navigator Spyder IDE Jupyter Notebook VS Code Git

Search 13,500+ shortcuts across 269 platforms

Explore All Platforms Practice Shortcuts
📜 Every shortcut on this page is taken from the official Python documentation — docs.python.org
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

🤖 Ask AI about Python shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok