{"id":6540,"library":"backports-shutil-get-terminal-size","title":"backports.shutil_get_terminal_size","description":"This library provides a pure Python backport of the `get_terminal_size` function, originally introduced in Python 3.3's `shutil` module. It allows applications targeting older Python versions (like Python 2.6, 2.7, and 3.2) to access terminal dimension information. Currently at version 1.0.0, the package was last updated in 2014, indicating a stable, low-cadence release cycle typical for a compatibility backport.","status":"maintenance","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/chrippa/backports.shutil_get_terminal_size","tags":["backport","terminal","shutil","compatibility","python2","python3"],"install":[{"cmd":"pip install backports-shutil-get-terminal-size","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The function resides within the `backports.shutil_get_terminal_size` package, not directly under `shutil_get_terminal_size`.","wrong":"from shutil_get_terminal_size import get_terminal_size","symbol":"get_terminal_size","correct":"from backports.shutil_get_terminal_size import get_terminal_size"}],"quickstart":{"code":"from backports.shutil_get_terminal_size import get_terminal_size\n\n# Get terminal dimensions\nterminal_size = get_terminal_size()\n\nprint(f\"Terminal columns: {terminal_size.columns}\")\nprint(f\"Terminal lines: {terminal_size.lines}\")","lang":"python","description":"This example demonstrates how to import and use the `get_terminal_size` function to retrieve the current terminal's column and line dimensions. The function returns a `terminal_size` named tuple with `columns` and `lines` attributes."},"warnings":[{"fix":"For Python 3.3+, use `from shutil import get_terminal_size` directly. This backport is for compatibility with older Python environments.","message":"This backport is primarily intended for Python versions older than 3.3. If you are using Python 3.3 or newer, `shutil.get_terminal_size` is built-in and should be used directly, making this package redundant. Installing it on newer Python versions will not cause issues but serves no practical purpose.","severity":"gotcha","affected_versions":"< 3.3"},{"fix":"No direct fix for performance; this is an inherent characteristic of the backport. Prefer the native `shutil.get_terminal_size` on Python 3.3+ for optimal performance.","message":"The backport is written in pure Python, unlike the native `shutil.get_terminal_size` in Python 3.3+ which has a C implementation. This means the backported version might be marginally slower in performance, though for most applications, the difference is negligible.","severity":"gotcha","affected_versions":"All versions of the backport"},{"fix":"Ensure `backports-shutil-get-terminal-size` is installed in an isolated virtual environment. If using `conda`, try `conda install backports.shutil_get_terminal_size` or re-installing `ipython` if the issue arises in that context. Verify correct import path `from backports.shutil_get_terminal_size import get_terminal_size`.","message":"Users have reported `ImportError` issues, particularly in mixed installation environments (e.g., pip and conda) or when other `backports` packages conflict. Sometimes the module is installed but not found correctly, or other `backports` packages interfere with the namespace.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}