prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.23k stars 280 forks source link

Cannot run `ptipython` before running `ptpython` #52

Open blink1073 opened 9 years ago

blink1073 commented 9 years ago

Thanks for this library! I tried running ptipython immediately after install, and got this traceback after every attempted execution. Once I forcibly exited, I ran a ptpython session just fine, and when I came back to ptipython, all was well.

FileNotFoundError                         Traceback (most recent call last)
/Users/ssilvester/anaconda/lib/python3.4/site-packages/ptpython/ipython.py in r)
    196         print('')
    197         try:
--> 198             string = self._cli.run().text
    199 acs   3/3   [F6] Paste mode (off)          [F2] Options - CPython 3.4.3
    200             # In case of multiline input, make sure to append a newline,

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/interface)
    271                 self._redraw()
    272
--> 273                 self.eventloop.run(self.input, self.create_eventloop_ca)
    274         finally:
    275             # Clean up renderer. (This will leave the alternate screen,e

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/eventloop)
     64                     # Feed input text.
     65                     data = stdin_reader.read()
---> 66                     inputstream.feed(data)
     67                     callbacks.redraw()
     68

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/terminal/)
    300             if c == '\r':
    301                 c = '\n'
--> 302             self._input_parser.send(c)
    303
    304     def flush(self):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/terminal/)
    252                 # Exact matches found, call handlers..
    253                 if (flush or not is_prefix_of_longer_match) and match:
--> 254                     self._call_handler(match, prefix)
    255                     prefix = ''
    256

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/terminal/)
    281                 self._call_handler(k, insert_text)
    282         else:
--> 283             self.feed_key_callback(KeyPress(key, insert_text))
    284
    285     def feed(self, data):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/interface)
    604         """
    605         # Feed the key and redraw.
--> 606         self.cli.input_processor.feed_key(key_press)
    607
    608     def redraw(self):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    163             self.beforeKeyPress.fire()
    164
--> 165         self._process_coroutine.send(key_press)
    166
    167         if key_press.key != Keys.CPRResponse:

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    135                 # Exact matches found, call handler.
    136                 if not is_prefix_of_longer_match and matches:
--> 137                     self._call_handler(matches[-1], key_sequence=buffer)
    138                     buffer = []
    139

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    174         event = Event(weakref.ref(self), arg=arg, key_sequence=key_sequ,
    175                       previous_key_sequence=self._previous_key_sequence)
--> 176         handler.call(event)
    177         self._registry.on_handler_called.fire(event)
    178

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
     24
     25     def call(self, event):
---> 26         return self._handler(event)
     27
     28     def __repr__(self):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
     28                 if safe_before:
     29                     event.cli.current_buffer.save_to_undo_stack()
---> 30                 handler_func(event)
     31             return handler_func
     32         return decorator

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/key_bindi)
    177         else:
    178             if b.accept_action.is_returnable:
--> 179                 b.accept_action.validate_and_handle(event.cli, b)
    180
    181     @handle(Keys.ControlK, filter= ~has_selection)

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/buffer.py)
     71                 self.handler(cli, buffer)
     72
---> 73             buffer.append_to_history()
     74
     75

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/buffer.py)
    889         # history is already the same.)
    890         if self.text and (not len(self._history) or self._history[-1] !:
--> 891             self._history.append(self.text)
    892
    893     def _search(self, search_state):

/Users/ssilvester/anaconda/lib/python3.4/site-packages/prompt_toolkit/history.p)
     70
     71         # Save to file.
---> 72         with open(self.filename, 'ab') as f:
     73             write = lambda t: f.write(t.encode('utf-8'))
     74

FileNotFoundError: [Errno 2] No such file or directory: '/Users/ssilvester/.ptp'
blink1073 commented 9 years ago
$ python --version
Python 3.4.3 :: Anaconda 2.2.0 (x86_64)
$ ipython --version
3.0.0
$ uname -a
Darwin 0202-ssilvester.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 20:23:44 PDT 2015; root:xnu-2782.20.48~8/RELEASE_X86_64 x86_64