Terminal de IPython#

The IPython Console allows you to execute commands and interact with data inside IPython interpreters.

Spyder IPython Console with code, inline plots, and the In prompt

To launch a new IPython console, go to New console (default settings) under the Consoles menu or from the Console context menu (right-clicking the pane tab bar). You can also use the keyboard shortcut Ctrl-T (Cmd-T on macOS) when the console is focused.

Desde el mismo menú, puedes dejar de ejecutar código con el Interrumpir el núcleo, limpia el namespace de una consola con Eliminar todas las variables, o relanza una nueva con Reiniciar el núcleo. Como cada consola se ejecuta en un proceso separado, esto no afectará a ningún otro que hayas abierto, y podrás probar fácilmente tu código en un entorno limpio sin interrumpir tu sesión principal.

Funciones disponibles#

Any IPython Console, whether external or started by Spyder, supports:

  • Completado automático de código

  • Información sobre la función en tiempo real

  • Full GUI integration with the Spyder Depurador (Debugger).

  • The Explorador de variables, with GUI-based editors for many built-in and third-party Python objects.

  • Integration with Spyder’s Gráficos pane to display Matplotlib graphics, if the Inline backend is selected under Preferences ‣ IPython console ‣ Graphics ‣ Graphics backend, and inline in the console if Mute inline plotting is unchecked under the Plots pane’s options menu.

For information on the features, commands and capabilities built into IPython itself, see the IPython documentation.

Consolas especiales#

Spyder also supports several types of specialized consoles. A Sympy console enables creating and displaying symbolic math expressions right inside Spyder. A Cython console allows you to use the Cython language to speed up your code and call C functions directly from Python. Finally, a Pylab console loads common NumPy and Matplotlib functions by default; while this is deprecated and strongly discouraged for new code over just importing the modules directly, it can still be used if necessary for legacy scripts that need it.

External and remote consoles#

You can open a new console in a remote environment you’ve set up using the Remote Connection Manager by selecting it under Consoles ‣ New console in remote server, or the equivalent item in the context menu. For more details about creating and managing remote connections, see the Remote Connection Manager documentation.

You can also open a new console tab connected to an existing running kernel, either local or remote, by using the advanced option Consoles ‣ Connect to existing kernel…. See Connecting to existing kernels (advanced) for more information.

Spyder showing connecting to an existing kernel

Menú de opciones#

The options («hamburger») menu on the top right of the pane allows you to inspect your current environment variables (Show environment variables), and the contents of your system’s PATH (Show sys.path contents). In addition, you can have each console display how long it has been running with Show elapsed time.

Spyder IPython Console with options menu

You can change the name of the current IPython console tab with the Rename tab option, or by simply double-clicking it.

Recargar módulos modificados#

When working with the normal interactive interpreter in the terminal, Python only loads a module from its source file once, the first time it is imported. This would require you to exit and relaunch the entire interpreter whenever you make changes to your code, losing any variables or functions you’ve defined in your session in the process.

El Recargador de Módulos de usuario (RMU) de Spyder recarga automáticamente módulos en las consolas de IPython existentes siempre que sean modificadas y reimportadas. Con la RMU activada, puedes probar los cambios en tu código sin reiniciar el núcleo.

Spyder showing reloading modules in console

UMR is enabled by default, and it will provide you with a red Reloaded modules: message in the console listing the files it has refreshed when it is activated. If desired, you can turn it on or off, and prevent specific modules from being reloaded, under Preferences ‣ Python interpreter ‣ User Module Reloader (UMR) ‣ Enable UMR.

Spyder preferences showing option to use module reloader