pipx
pipx copied to clipboard
Malformed characters when using "pipx run file:[file.py]" command with Rich library
Describe the bug
When using pipx file:[file.py] on a file importing the Rich Library system the display seems to be malformed when using tables and progress bars. If I run this normally using the standard python command with the libraries installed; Both in and out of a virtualenv and on 2 different windows machine in both CMDER and Fluent Terminal...it works as expected.
python 3.11 pipx 1.5.0
I have made sure to try all the steps on the Troubleshooting page before submitting
How to reproduce
Running the script with Rich library installed using the script comment at the top of the file;
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "typer",
# "rich",
# ]
# ///
Expected behavior
See included screen gif
Rich output from python -m rich
It might have something to do with the charset encoding settings of the stdout/stderr pipeline connection between console <-> pipx <-> python. I repro'd this with:
-
richmain.py
:
# /// script
# requires-python = ">=3.11"
# dependencies = [ "typer", "rich" ]
# ///
import runpy
runpy.run_module("rich.__main__", run_name="__main__")
- execute:
pipx run file:richmain.py
- repro.
afterwards you can run to test this has no repro:
$cachedir = pipx environment -V PIPX_VENV_CACHEDIR
$venv = dir $cachedir -dir | sort lastmodifiedtime -descending | select -first 1
& "$venv\scripts\activate.ps1"
python -m rich
(probably need to be using Windows Terminal to support this kind of rich output)
Also see: https://github.com/pypa/pipx/issues/209