[Help] I cannot use Rich's color printing in RUN or DEBUG of PyCharm
Describe the bug
I cannot use Rich's color printing in RUN or DEBUG of PyCharm, but I can use it in CMD or Powershell of Windows. Is it my setting or use problem? I couldn't find the question on Google..
**platform **
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using? windows10
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.
If you're using Rich in a terminal:
python -m rich.diagnose
pip freeze | grep rich

This is the printout result of my Run or Debug in Pycharm

But I can use it in Powershell

PyCharm doesn't behave like a terminal by default. There is a checkbox somewhere that enables terminal emulation. Search closed issues for a solution.
Screen shot on the "Emulate terminal in output console" is here:
- https://stackoverflow.com/a/45534743
@willmcgugan are there any plans to try and get things working with the PyCharm console? It's got a lot of great features so going to a plain terminal is a big step backwards. On the other hand, it's so damn ugly and Rich is so pretty :) it would be wonderful if I could get the best of both worlds.
There’s nothing I can do. The issue is with PyCharm.
Edit: I just found the force_terminal=True option, that's good enough for me...
Original comment: Are you aware that the PyCharm console supports quite a lot of what you do with Rich? If I trick Rich into thinking it's in a terminal, the output is pretty good:

So if you wanted to support PyCharm, it seems like at least a decent subset of the features could be made to work, but I have no idea how much effort it would be and whether or not that's a goal of yours.
does this still work for you? @davidgilbertson - i can't reproduce this on windows
Yep just tried in current PyCharm and this code outputs pretty content as above.
It still only works if you make isatty return False, so that's still not handled internally by rich. I guess PyCharm support is not a priority.
This is on Windows using iPython or the Python Console in PyCharm.
import sys
import rich
sys.stdout.isatty = lambda: True
rich.print(locals())
console = rich.console.Console()
console.print("Hello, World!", style="bold red")
console.print(
"Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i]."
)
my_list = ["foo", "bar"]
rich.inspect(my_list, methods=True)
table = rich.table.Table(show_header=True, header_style="bold magenta")
table.add_column("Date", style="dim", width=12)
table.add_column("Title")
table.add_column("Production Budget", justify="right")
table.add_column("Box Office", justify="right")
table.add_row(
"Dec 20, 2019",
"Star Wars: The Rise of Skywalker",
"$275,000,000",
"$375,126,118",
)
table.add_row(
"May 25, 2018",
"[red]Solo[/red]: A Star Wars Story",
"$275,000,000",
"$393,151,347",
)
table.add_row(
"Dec 15, 2017",
"Star Wars Ep. VIII: The Last Jedi",
"$262,000,000",
"[bold]$1,332,539,889[/bold]",
)
console.print(table)