Commands
Curated shell and tool commands for Linux, Windows, Python, Git, Django, SQL, and Nginx – searchable, filterable, and copyable with one click.
29 Commands found
No commands found. Try a different search or filter.
-
Python Bash
Benchmark a small snippet of Python code
Runs the given expression repeatedly and reports the average execution time, using the standard library timeit module. Useful for comparing the performance of small code snippets; has no side effects beyond CPU time.
python -m timeit "sum(range(1000))" -
Python Bash
Check a script for syntax errors by compiling it
Compiles the given Python file to bytecode without executing it, which is a quick way to check for syntax errors. Replace example.py with the path to an actual, already existing file; writes a compiled .pyc file into a __pycache__ subdirectory next to the source file, creating that directory if it does not already exist.
python -m py_compile example.py -
Python Bash
Check installed packages for dependency conflicts
Verifies that all installed packages have their required dependencies satisfied and reports any version conflicts. Read-only; does not install, upgrade, or remove anything.
python -m pip check -
Python Bash
Check whether a requirements file would install cleanly
Resolves the dependencies listed in requirements.txt and reports whether they could be installed, without actually installing, upgrading, or removing any of the target packages. Requires a requirements.txt file in the current directory and pip 22.2 or later for the --dry-run flag. It can still download package files to resolve versions and build metadata, write to pip's local cache directory, and run package build steps as needed to determine compatibility.
python -m pip install --dry-run -r requirements.txt -
Python Bash
Check whether a specific module can be imported
Uses importlib.util.find_spec to check whether the named module (json in this example) can be located on the import search path, without actually importing or executing it; prints the module's spec if found, otherwise None. A found spec only means a matching file or package exists at an importable location; it does not guarantee that importing the module will actually succeed, since the module's own code could still fail during import (e.g. a syntax error or a missing dependency it tries to import internally). Replace json with the name of any other module to check it instead. Read-only and much faster than scanning every importable module.
python -c "import importlib.util; print(importlib.util.find_spec('json'))" -
Python Python
Check whether a virtual environment is active
Compares sys.prefix with sys.base_prefix in the running interpreter; prints True if a virtual environment is currently active, otherwise False. Read-only, uses only the standard library.
import sys; print(sys.prefix != sys.base_prefix) -
Python Bash
Create a new JSON file without overwriting an existing one
Creates a file named example.json in the current directory containing a small, indented JSON document, using only the standard library json and pathlib modules. Opens the file in exclusive creation mode ('x'), so the command fails with a FileExistsError and does not touch the file's contents if example.json already exists in the current directory.
python -c "import json, pathlib; f = pathlib.Path('example.json').open('x'); json.dump({'example': True}, f, indent=2); f.close()" -
Python Bash
Create a virtual environment
Creates an isolated Python virtual environment in a new .venv folder in the current directory, with its own interpreter and pip. Available since Python 3.3. If .venv already exists, Python's venv module reuses that directory instead of failing: it recreates the interpreter links/copies, activation scripts, and pyvenv.cfg, and reinstalls pip unless --without-pip is given, but it does not delete unrelated files or already-installed packages unless --clear is also passed; mixing this with an existing environment built from a different Python version can leave it in an inconsistent state.
python -m venv .venv -
Python Bash
Debug a script interactively with pdb
Launches the standard library debugger and starts executing the given script under its control, stopping before the first line so breakpoints and stepping commands can be used. Replace example.py with the path to an actual, already existing script; this opens an interactive debugging prompt and does not return control until the session is exited by entering continue or quit.
python -m pdb example.py -
Python Bash
Discover and run unittest test cases
Automatically finds and runs test files in the current directory tree using the standard library unittest framework, printing verbose results. Requires test files following unittest's discovery naming convention (test*.py by default); actual side effects depend entirely on what the discovered tests do.
python -m unittest discover -v -
Python Bash
Inspect pip cache usage
Show locations, sizes and entry counts of the configured pip cache without clearing it. The cache may be shared across Python environments.
python -m pip cache info -
Python Bash
Inspect Python source tokens
Print lexical tokens from a syntactically valid example.py without executing the source code. Replace the filename.
python -m tokenize example.py -
Python Bash
List a TAR archive
List the contents of example.tar with Python's standard library without extracting files. Replace the archive path.
python -m tarfile -l example.tar -
Python Bash
List a ZIP archive
List the contents of example.zip with Python's standard library without extracting files. Replace the archive path.
python -m zipfile -l example.zip -
Python Python
List currently loaded modules in this session
Shows the names of all modules already imported into the running interpreter session, sorted alphabetically. This differs from installed packages: it only reflects what has actually been imported so far, not everything available. Read-only.
import sys; print(sorted(sys.modules.keys())) -
Python Bash
List installed packages with available updates
Checks every installed package against PyPI and lists those with a newer version available. Requires a working internet connection and may take a moment; does not install or change anything.
python -m pip list --outdated -
Python Bash
List installed Python packages
Lists installed Python packages and their versions in the active environment. Requires pip.
python -m pip list -
Python Python
Parse a JSON string and read a value
Parses a small JSON string into a Python dictionary using the standard library json module and prints one of its values. Self-contained example; does not read or write any file.
import json; data = json.loads('{"example": true}'); print(data["example"]) -
Python Bash
Print a text calendar for the current year
Uses the standard library calendar module to print a full-year text calendar for the current calendar year, as determined by the system clock when the command runs. Pass an explicit year as an argument, e.g. python -m calendar 2027, to print a different year instead. Read-only, output only.
python -m calendar -
Python Bash
Profile a script's execution time by function
Runs the given script under the standard library cProfile profiler and prints a report of time spent in each function, sorted by cumulative time. Replace example.py with the path to an actual, already existing script; this actually executes that script, so any side effects it has will occur as normal.
python -m cProfile -s cumulative example.py -
Python Bash
Profile how long each import takes
Runs the given code with the importtime flag, printing a breakdown of how much time each imported module took to load, including its dependencies. Available since Python 3.7; read-only, no side effects beyond the import itself.
python -X importtime -c "import json" -
Python Bash
Run doctest examples embedded in a module
Executes the interactive examples found in the docstrings of the given file and reports whether their output matches, with verbose details. Replace example.py with the path to an actual Python file containing doctest-style examples in its docstrings; the file must already exist. Has no effect on files without such examples.
python -m doctest -v example.py -
Python Bash
Serve a local directory over HTTP
Starts a simple HTTP server using the standard library http.server module, serving only the files inside a subdirectory named public (relative to the current directory), bound exclusively to the local machine (127.0.0.1) on port 8000. Requires that a public directory already exists in the current directory; create one first if needed. Runs in the foreground until stopped with Ctrl+C and does not modify any files, but does make the public directory's contents accessible via HTTP to anyone on the local machine while it runs. This built-in server is intended for local testing only and is not suitable for production use.
python -m http.server 8000 --bind 127.0.0.1 --directory public -
Python Bash
Show metadata for an installed package
Prints version, location, and dependency metadata for the named package. Uses pip itself as the example here because it is commonly available in most Python installations, though not guaranteed: some Linux distributions ship a base python3 package without pip (requiring a separate OS package), virtual environments can be created with --without-pip, and minimal or embeddable Python builds may omit it entirely. Replace pip with the name of any other installed package, such as django, to inspect it instead. Fails with a non-zero exit code if the given package is not installed. Read-only.
python -m pip show pip -
Python Bash
Show Python installation and site-packages paths
Prints the module search path (sys.path), the site-packages directories, and whether per-user site-packages are enabled. Read-only, standard library only.
python -m site -
Python Bash
Show Python version
Prints the version of the Python interpreter available as `python` on the PATH.
python --version -
Python Python
Show the active Python interpreter path
Prints the full path of the Python executable currently running this session. Useful for confirming that the expected interpreter, such as one inside a virtual environment, is actually active. Read-only.
import sys; print(sys.executable) -
Python Bash
Start the local Python documentation browser
Starts a local documentation server and attempts to open it in a browser; opening a browser may fail on a headless server. When documenting modules, pydoc may import Python modules, which can execute their module-level code and cause side effects. Do not assume this command is read-only.
python -m pydoc -b -
Python Bash
Validate and pretty-print a JSON file
Parses the given file as JSON and prints it reformatted with indentation, or reports a syntax error with the exact position if the file is not valid JSON. Replace example.json with the path to an actual, already existing file; prints to standard output only and does not modify the input file.
python -m json.tool example.json