Help with Rich package

Question:
How can I get rich to work properly
I have only been able to get it to work when doing pip install rich, but some things are missing and it has to reinstall rich on every run.
When trying to install rich through packages package operation fails.

import rich
1 Like

Hello, @MiloCat. I believe the problem is with how you imported rich; you should do something like from rich.console import Console, from rich import print, from rich import pretty, and so on.

@Sky

thanks, lol i just opened my tab at the moment you responded!
How can I import the library for hex code colors?
The weird thing is that rich is still reinstalled every time I run my repl. Also I still have this error:
Traceback (most recent call last):
File “main.py”, line 2, in
console.print(“DANGER!”, style=“red on white”)
AttributeError: module ‘rich.console’ has no attribute ‘print’
code:

from rich import console,style,print
console.print("DANGER!", style="red on white")

noo omg you have to do:

from rich.console import Console

console = Console()
console.print("DANGER~", style="red on white")

bruh errors:
ima invite you:
Errors with ur code:
Traceback (most recent call last):
File “main.py”, line 1, in
from rich import Console
ImportError: cannot import name ‘Console’ from ‘rich’ (/home/runner/RichTryout/venv/lib/python3.8/site-packages/rich/init.py)
Errors with that error fixed:
Traceback (most recent call last):
File “main.py”, line 3, in
console().print(“DANGER~”, style=“red on white”)
TypeError: ‘module’ object is not callable

You have to do pip install rich in the Replit Shell for your Repl. Then Rich will work!

no he kept importing it wrong he was doing from rich import Console when its from rich.console import Console.

so how would I import colors?
like this?:

from rich.console import style

You are referring to documentation things, please refer to rich’s documentation. In your case, specifically, the style section

Okay, thanks :slight_smile:
also I though you were taking a break from replit @bigminiboss?

2 Likes

I am, I will sometimes help on the ask forums, however

ok nice thats great :smiley:

dude I showed him multiple times and even wrote it in his code

lol I know, I just thought I should point them directly to the documentation

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.