¡Usando Python atornilla la carcasa (¿y/o el terminal?)!

El problema

Simplemente abriendo y cerrando la subcapa de Python atornilla mi caparazón (¿o posiblemente el terminal?). Parece eliminar la capacidad del shell para imprimir cualquier texto que ingrese, incluidas las líneas nuevas después de ingresar un comando.

El problema ocurre para python3.4, python2.7 y python2.6, pero no para python2.5.

Nunca antes había ocurrido (que yo haya notado), y no sucede con otros paquetes de software que he usado (VIM, Emacs, etc.).

He confirmado que se rompe usando la Terminal estándar de Apple (Versión 2.2.3 [303.2]), iTerm2 (compilación 2.1.1) y XTerm (269).

Curiosamente, se rompe bajo bash, pero no zsho csh.

Comportamiento de ejemplo

Para demostrarlo, hago lo siguiente ( $SHELLes /bin/bash):

  1. corre which python3.4_
  2. corre python3.4_
  3. Presione la tecla Retorno una vez, luego ingrese exit()al shell de Python.
  4. Pulse Retorno dos veces más.
  5. Entrar python3.4 --version_

Esto es lo que veo para algunas de las versiones principales de Python que he instalado:

Python3.4 -- problemático

myself@localhost:~$ which python3.4
python3.4 is /opt/local/bin/python3.4
python3.4 is /opt/local/bin/python3.4
myself@localhost:~$ python3.4
Python 3.4.3 (default, Aug 24 2015, 17:25:38)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> myself@localhost:~$ myself@localhost:~$ myself@localhost:~$ Python 3.4.3
myself@localhost:~$

Python2.7 -- problemático

myself@localhost:~$ which python2.7
python2.7 is /opt/local/bin/python2.7
python2.7 is /usr/local/bin/python2.7
python2.7 is /usr/bin/python2.7
python2.7 is /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
python2.7 is /usr/bin/python2.7
python2.7 is /usr/local/bin/python2.7
python2.7 is /opt/local/bin/python2.7
myself@localhost:~$ python2.7
Python 2.7.10 (default, Aug 24 2015, 11:54:49)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> myself@localhost:~$ myself@localhost:~$ myself@localhost:~$ Python 2.7.10
myself@localhost:~$

Python2.6 -- problemático

myself@localhost:~$ which python2.6
python2.6 is /opt/local/bin/python2.6
python2.6 is /usr/bin/python2.6
python2.6 is /usr/bin/python2.6
python2.6 is /opt/local/bin/python2.6
myself@localhost:~$ python2.6
Python 2.6.9 (unknown, Aug 24 2015, 17:53:21)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> myself@localhost:~$ myself@localhost:~$ myself@localhost:~$ Python 2.6.9
myself@localhost:~$

Python2.5 -- ¡Funciona!

myself@localhost:~$ which python2.5
python2.5 is /usr/bin/python2.5
python2.5 is /usr/bin/python2.5
myself@localhost:~$ python2.5
Python 2.5.6 (r256:88840, Jul 31 2011, 19:30:45)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
myself@localhost:~$
myself@localhost:~$
myself@localhost:~$ python2.5 --version
Python 2.5.6
myself@localhost:~$

Ejecutándolo zsho cshparece funcionar bien:

Zsh

myself@localhost:~$ zsh
localhost% which python3.4
/opt/local/bin/python3.4
localhost%
localhost% python3.4
Python 3.4.3 (default, Aug 24 2015, 17:25:38)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> %                                                                           
ra%
ra%
ra% python3.4 --version
Python 3.4.3
localhost% exit
myself@localhost:~$

efectivo

myself@localhost:~$ csh
Running csh
[localhost:~] myself% which python3.4
/opt/local/bin/python3.4
[localhost:~] myself% python3.4
Python 3.4.3 (default, Aug 24 2015, 17:25:38)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> [localhost:~] myself%
[localhost:~] myself%
[localhost:~] myself% python3.4 --version
Python 3.4.3
[localhost:~] myself% exit
exit

Mi pensamiento hasta ahora:

El hecho de que el comportamiento parezca el mismo para tres terminales me hace pensar que no es un problema de terminal.

El hecho de que funcione en Zsh y Csh pero no en Bash me hace pensar que es un problema de shell.

El hecho de que las versiones que fallan (3.4, 2.7, 2.6) estén todas instaladas en /opt/local/bin/(la ubicación de instalación habitual de MacPorts), pero la versión que funciona (2.5) está instalada en /usr/bin/, me hace preguntarme si alguna actualización reciente de MacPorts (quizás empujada hasta 20 días antes del 24 de agosto de 2015 ??) puede haber roto algo que hace que Python y Bash no funcionen juntos.

Una suposición: las pitones macports no están comprometidas con GNU readline; intente instalar pyXX-readline
Además de la solución @Mark y hasta que se solucione el problema, cuando salga de python con exit() , quit()o control Describa reseten el indicador (no se repetirá en la terminal) y espere hasta que vuelva a aparecer el indicador.
@Mark: ¡Eso funcionó! Si lo escribes como respuesta, lo aceptaré. ¡Gracias un montón!

Respuestas (1)

Parece que hay un problema con las compilaciones recientes de Macports de python. Vea este error .

Una solución alternativa es instalar pyXX-readline (py35-readline se ha producido solo para este error)

Otra es instalar python agregando la variante +readline