问题
So I've got a problem. I installed Anaconda with Python 3.5.2 and when I go for cmd>python
then interpreter is on, and then when I try:
for i in range(10):
print(i)
Then a message pops out (when I press TAB):
Readline internal error
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
res = ensure_str(readline_hook(prompt))
File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
self._readline_from_keyboard()
File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
if self._readline_from_keyboard_poll():
File "C:\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
result = self.mode.process_keyevent(event.keyinfo)
File "C:\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
r = self.process_keyevent_queue[-1](keyinfo)
File "C:\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
r = dispatch_func(keyinfo)
File "C:\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
completions = self._get_completions()
File "C:\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
r = self.completer(ensure_unicode(text), i)
File "C:\Anaconda3\lib\rlcompleter.py", line 80, in complete
readline.redisplay()
AttributeError: module 'readline' has no attribute 'redisplay'
It's okay when I go for 2 spaces though. Can I set Anaconda to accept TAB indents as well?
回答1:
It looks like the tab key performs a different function indentation. It is mapped to "redisplay". I think you'll either have to change the config to allow tab indentation or use spaces.
回答2:
for i in range(10):press Enter ... print(i)--- between last dot and p, insert three spaces and hit Enter. In the next line there will be three dots and the (blinking) cursor is one space after the last dot.
Press enter and you see the output
This was in Windows 10 Insiders Preview Build 17127.rs4_release and Python 3.6.2
来源:https://stackoverflow.com/questions/39077179/set-a-python-indent-in-anaconda