So I've been trying to code a multiple choice question with the 'inquirer' function. The problem is that when I run it this appears with dozens of lines I don't understand:
error: (25, 'Inappropriate ioctl for device')
There should normally be no error in the code since I copy and pasted the model, so I have no idea on what's wrong. I'd be super grateful for any help. By the way, I use Jupyter Notebook.
So here's what the code looks like :
name = input("What's your name ? ")
options = ['Social media', 'Ads', 'TV', 'Other']
questions = [
inquirer.List('options',
message = 'Welcome,' + name + '. How did you find out about this app?',
choices = options,
),
]
answers = inquirer.prompt(questions)
print(answers)
print(answers['options'])
When I run it, it prints the choices the user is supposed to select from:
[?] Welcome,David. How did you find out about this app?: Social media
> Social media
Ads
TV
Other
And immediately after, all this pops up:
error Traceback (most recent call last)
Cell In[25], line 25
17 options = ['Social media', 'Ads', 'TV', 'Other']
19 questions = [
20 inquirer.List('options',
21 message = 'Welcome,' + name + '. How did you find out about this app?',
22 choices = options,
23 ),
24 ]
---> 25 answers = inquirer.prompt(questions)
26 print(answers)
27 print(answers['options'])
File ~/anaconda3/lib/python3.10/site-packages/inquirer/prompt.py:11, in prompt(questions, render, answers, theme, raise_keyboard_interrupt)
9 try:
10 for question in questions:
---> 11 answers[question.name] = render.render(question, answers)
12 return answers
13 except KeyboardInterrupt:
File ~/anaconda3/lib/python3.10/site-packages/inquirer/render/console/__init__.py:38, in ConsoleRender.render(self, question, answers)
35 self.clear_eos()
37 try:
---> 38 return self._event_loop(render)
39 finally:
40 print("")
File ~/anaconda3/lib/python3.10/site-packages/inquirer/render/console/__init__.py:51, in ConsoleRender._event_loop(self, render)
48 self._print_header(render)
49 self._print_options(render)
---> 51 self._process_input(render)
52 self._force_initial_column()
53 except errors.EndOfInput as e:
File ~/anaconda3/lib/python3.10/site-packages/inquirer/render/console/__init__.py:95, in ConsoleRender._process_input(self, render)
93 def _process_input(self, render):
94 try:
---> 95 ev = self._event_gen.next()
96 if isinstance(ev, events.KeyPressed):
97 render.process_input(ev.value)
File ~/anaconda3/lib/python3.10/site-packages/inquirer/events.py:22, in KeyEventGenerator.next(self)
21 def next(self):
---> 22 return KeyPressed(self._key_gen())
File ~/anaconda3/lib/python3.10/site-packages/readchar/_posix_read.py:34, in readkey()
30 def readkey() -> str:
31 """Get a keypress. If an escaped key is pressed, the full sequence is
32 read and returned as noted in `_posix_key.py`."""
---> 34 c1 = readchar()
36 if c1 in config.INTERRUPT_KEYS:
37 raise KeyboardInterrupt
File ~/anaconda3/lib/python3.10/site-packages/readchar/_posix_read.py:18, in readchar()
14 """Reads a single character from the input stream.
15 Blocks until a character is available."""
17 fd = sys.stdin.fileno()
---> 18 old_settings = termios.tcgetattr(fd)
19 term = termios.tcgetattr(fd)
20 try:
error: (25, 'Inappropriate ioctl for device')
Please help me...