Registry / backports-shutil-get-terminal-size

backports-shutil-get-terminal-size

JSON →
library1.0.0pypypi✓ verified 86d ago

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.

pip install backports-shutil-get-terminal-size
INSTALL
IMPORT
SIG · BACKPORTS-SHUTIL-G
B
backports-shutil-get-terminal-size
pythonv1.0.0
Install
1.5s avg
Import
26ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.021s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.032s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_terminal_size
from backports.shutil_get_terminal_size import get_terminal_size
from shutil_get_terminal_size import get_terminal_size
The function resides within the `backports.shutil_get_terminal_size` package, not directly under `shutil_get_terminal_size`.

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.

from backports.shutil_get_terminal_size import get_terminal_size # Get terminal dimensions terminal_size = get_terminal_size() print(f"Terminal columns: {terminal_size.columns}") print(f"Terminal lines: {terminal_size.lines}")
Debug
Known issues
gotchaThis 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.
fix
For Python 3.3+, use `from shutil import get_terminal_size` directly. This backport is for compatibility with older Python environments.
affects: < 3.3
gotchaThe 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.
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.
affects: All versions of the backport
gotchaUsers 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.
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`.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named backports.shutil_get_terminal_size
This error typically occurs when the `backports.shutil_get_terminal_size` package is not correctly installed or is not accessible in the current Python environment, often due to conflicts between pip and conda, or issues with site-packages on older Python versions (e.g., Python 2.7), especially when it's a dependency of another library like IPython.
fix
Ensure the package is correctly installed using `pip install backports.shutil_get_terminal_size` or, if using Anaconda, `conda install backports.shutil_get_terminal_size` after adding the `conda-forge` channel. If problems persist, try reinstalling the dependent package (e.g., IPython) or setting up a clean virtual environment.
ImportError: No module named shutil_get_terminal_size
This is a variant of the `ImportError` where the Python interpreter cannot find the `shutil_get_terminal_size` module, usually when trying to import it directly or via another backports mechanism. It's often linked to the same underlying installation or environment issues as the previous error.
fix
Verify that `backports.shutil_get_terminal_size` is installed correctly. For Python versions 3.3 and above, you should directly import `get_terminal_size` from the standard `shutil` module, as the backport is unnecessary. If on older Python, ensure the backport is installed and reachable by the Python path.
AssertionError: backports-shutil_get_terminal_size .dist-info directory not found
This error occurs during the installation of `backports-shutil_get_terminal_size` via `pip` (specifically with older pip versions, e.g., 8.1.2), indicating a packaging issue where pip expects a `.dist-info` directory but finds it misnamed or structured incorrectly within the downloaded package.
fix
Upgrade your `pip` and `setuptools` to the latest versions using `pip install --upgrade pip setuptools`. If the issue persists, consider installing the package directly from its GitHub source or using a package manager like `conda` if available.
ImportError: No module named 'backports'
This error occurs when a module attempts to import from the `backports` namespace, but the top-level `backports` package itself is not found, often happening when a sub-package like `backports.shutil_get_terminal_size` is expected but the base `backports` infrastructure isn't properly installed or configured, especially in Python 3 environments where this backport might be implicitly pulled in as a dependency but isn't needed or compatible.
fix
Ensure that if `backports.shutil_get_terminal_size` is a dependency, it is properly installed. If you are on Python 3.3 or newer, the `shutil.get_terminal_size` function is built-in and the backports library is not required; check if a dependent library is unnecessarily trying to use the backport.
Upgrade
Version history
1.0.0latest on PyPI · released Aug 19, 2014
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
backports-shutil-get-terminal-size — pip install backports-shutil-get-terminal-size · libregistry