yaspin is a Python library that provides a simple and flexible way to display terminal spinners for CLI applications, indicating ongoing operations. It is currently at version 3.4.0 and maintains a regular release cadence, often updating with new features, dependency bumps, and Python version support.
pip install yaspinVerified import paths — ran on the pinned version, not inferred.
The most common way to use yaspin is as a context manager, wrapping your time-consuming operations. You can customize the spinner type, text, and colors, and then finalize with success or failure indicators.
Upgrade your Python environment to 3.10 or a later supported version (3.10, 3.11, 3.12, 3.13, 3.14 are supported by v3.4.0).
Review the official documentation for v3.0.0+ for updated API usage. Direct imports from these internal modules or reliance on COLOR_MAP will no longer work.
Avoid using `is_jupyter()`. If you need to detect a Jupyter environment, consider alternative methods or check the yaspin documentation for recommended practices.
If encountering unwanted control characters in piped output, ensure you are on a recent `yaspin` version and consider using `sys.stdout.isatty()` checks in your code to conditionally disable `yaspin` or redirect its output to `sys.stderr` when `stdout` is not a TTY.
If using yaspin in a multithreaded context, ensure that other threads do not write directly to `sys.stdout` while the spinner is active, or use `yaspin.write()` for thread-safe output. Consider using a `threading.Lock` to manage console access if conflicts arise.
Install the library using pip: `pip install yaspin`
Import the `Spinner` class directly from the `yaspin` module: `from yaspin import Spinner` Or, use the `yaspin` convenience function if that was your intention: `from yaspin import yaspin`
Run your Python script directly from a standard terminal emulator (like `cmd.exe`, PowerShell, bash, zsh) instead of an IDE's internal console. Ensure `sys.stdout.isatty()` returns `True` in your execution environment.
Change your terminal's encoding to UTF-8 using `chcp 65001` before running the Python script. Alternatively, configure `yaspin` to use an ASCII-only spinner set.
```bash
chcp 65001
python your_script.py
```
Or in Python:
```python
from yaspin import yaspin, SPHINX
with yaspin(spinner=SPHINX) as sp: # Use a simpler ASCII spinner
sp.text = "Processing..."
```