0
import pyfiglet from termcolor import colored total_colors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"] msg = input("What would you like to print? ") col = input("what color?") if col not in total_colors: col = "green" ascii_art = pyfiglet.figlet_format(msg) colored_ascii = colored(ascii_art, color=col) print(colored_ascii) 

ImportError: cannot import name 'figlet_format' from 'pyfiglet'

4
  • Please add the full error traceback to your question! Commented Apr 14, 2020 at 5:33
  • It may be a wrapper on the figlet program (a separate program from Python). You might have to install figlet as well. Commented Apr 14, 2020 at 5:37
  • 1
    The code works for me, maybe try to reinstall pyfiglet? Commented Apr 14, 2020 at 5:40
  • I suspect a name clash. Is there anything called pyfiglet in your project? Commented Apr 14, 2020 at 5:44

2 Answers 2

1

There are some issues i see in your program.

1.install pyfiglet module
pip install pyfiglet

2.msg = input("What would you like to print? ")
no need to take in put on this line as next line takes input and logic of your program is based on the next input

3.ascii_art = pyfiglet.figlet_format(msg) colored_ascii = colored(ascii_art, color=col) print(colored_ascii)

The above line should be

ascii_art = pyfiglet.figlet_format(col) colored_ascii = colored(ascii_art, color=col) print(colored_ascii)

I installed the pyfiglet module and did implement modified program

import pyfiglet from termcolor import colored total_colors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"] msg = print("What would you like to print? ") col = input("what color?") if col not in total_colors: col = "green" ascii_art = pyfiglet.figlet_format(col) colored_ascii = colored(ascii_art, color=col) print(colored_ascii) 

Output:

What would you like to print? what color?blue [34m _ _ | |__ | |_ _ ___ | '_ \| | | | |/ _ \ | |_) | | |_| | __/ |_.__/|_|\__,_|\___| [0m 
Sign up to request clarification or add additional context in comments.

1 Comment

thnx. the problem was with the file name
0

I know it sounds obvious but make sure that the lib is installed on your computer. If it is then make sure the lib is installed the same place your Python is installed.

1 Comment

the problem was with the file name.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.