Beruflich Dokumente
Kultur Dokumente
Release 3
Pierre Raybaut
1 Overview 3
2 Installation 5
2.1 Installing on Windows Vista/7/8/10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Installing on MacOS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Installing on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Installing or running directly from source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 Installing the development version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6 Help and support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Editor 13
4.1 How to define a code cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5 IPython Console 17
5.1 Reloading modules: the User Module Reloader (UMR) . . . . . . . . . . . . . . . . . . . . . . . . . 19
6 Debugging 21
6.1 Debugging with pdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7 Console 23
8 Variable Explorer 25
8.1 Supported types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
9 Help 31
10 Projects 35
10.1 Version Control Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
12 File Explorer 41
13 History log 45
14 Find in files 47
i
15 Online help 49
16 Internal Console 51
ii
Spyder Documentation, Release 3
Contents 1
Spyder Documentation, Release 3
2 Contents
CHAPTER 1
Overview
* working directory
* command line options
* run in a new Python interpreter or in an existing Python interpreter or IPython client
* Python interpreter command line options
3
Spyder Documentation, Release 3
* code completion
* calltips
* go-to-definition: go to object (any symbol: function, class, attribute, etc.) definition by pressing
Ctrl+Left mouse click on word or Ctrl+G (default shortcut)
– occurrence highlighting
– typing helpers (optional):
* GUI-based editors for a lot of data types (numbers, strings, lists, arrays, dictionaries, ...)
* import/export data from/to a lot of file types (text files, !NumPy files, MATLAB files)
* multiple array/list/dict editor instances at once, thus allowing to compare variable contents
* data visualization
• History log
• Help:
– provide documentation or source code on any Python object (class, function, module, ...)
– documentation may be displayed as an html page thanks to the rich text mode (powered by sphinx)
• Online help: automatically generated html documentation on installed Python modules
• Find in files: find string occurrences in a directory, a mercurial repository or directly in PYTHONPATH (support
for regular expressions and included/excluded string lists)
• File Explorer
• Projects
Spyder may also be used as a PyQt5 or PyQt4 extension library (module ‘spyder’). For example, the Python interactive
shell widget used in Spyder may be embedded in your own PyQt5 or PyQt4 application.
4 Chapter 1. Overview
CHAPTER 2
Installation
Spyder is quite easy to install on Windows, Linux and MacOS X. Just the read the following instructions with care.
If you want to install Spyder directly, you need to follow these steps:
1. Install the essential requirements:
• The Python programming language
• PyQt5 (recommended) or PyQt4
2. Install Spyder and its dependencies by running this command:
5
Spyder Documentation, Release 3
Updating Spyder
Installing on MacOS X
Thanks to the Spyder team and Continuum, you have two alternatives:
1. Use the Anaconda Python distribution.
2. Use our DMG installers, which can be found here.
Note: The minimal version to run our DMG’s is Mavericks (10.9) since Spyder 2.3.5. Previous versions
work on Lion (10.7) or higher.
Thanks to the MacPorts project, Spyder can be installed using its port package manager. There are several versions
available from which you can choose from.
Warning: It is known that the MacPorts version of Spyder is raising this error: ValueError:
unknown locale: UTF-8, which doesn’t let it start correctly.
To fix it you will have to set these environment variables in your ~/.profile (or ~/.bashrc)
manually:
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
6 Chapter 2. Installation
Spyder Documentation, Release 3
Installing on Linux
Please refer to the Requirements section to see what other packages you might need.
1. Ubuntu:
• Using the official package manager: sudo apt-get install spyder.
Note: This package could be slightly outdated. If you find that is the case, please use the Debian package
mentioned below.
Requirements
Optional modules
Installation procedure
1. If you use Anaconda, you need to run this command to install Spyder:
conda install spyder
2. If you don’t use Anaconda, you need to run:
pip install --upgrade spyder
You can execute Spyder without installing it first by following these steps:
1. Unzip the source package
2. Change current directory to the unzipped directory
3. Run Spyder with the command python bootstrap.py
4. (Optional) Build the documentation with python setup.py build_doc.
This is especially useful for beta-testing, troubleshooting and development of Spyder itself.
8 Chapter 2. Installation
Spyder Documentation, Release 3
If you want to try the next Spyder version, you have to:
1. Install Spyder requirements
2. Install Git, a powerful source control management tool.
3. Clone the Spyder source code repository with the command:
git clone https://github.com/spyder-ide/spyder.git
4. To keep your repository up-to-date, run
git pull
inside the cloned directory.
5. (Optional) If you want to read the documentation, you must build it first with the command
python setup.py build_doc
Spyder websites:
• For bug reports and feature requests you can go to our website.
• For discussions and help requests, you can suscribe to our Google Group.
10 Chapter 2. Installation
CHAPTER 3
11
Spyder Documentation, Release 3
Editor
Spyder’s text editor is a multi-language editor with features such as syntax coloring, code analysis (real-time code
analysis powered by pyflakes and advanced code analysis using pylint), introspection capabilities such as code com-
pletion, calltips and go-to-definition features (powered by rope), function/class browser, horizontal/vertical splitting
features, etc.
Function/class/method browser:
13
Spyder Documentation, Release 3
14 Chapter 4. Editor
Spyder Documentation, Release 3
A “code cell” is a concept similar to MATLAB’s “cell” (except that there is no “cell mode” in Spyder), i.e. a block
of lines to be executed at once in the current interpreter (Python or IPython). Every script may be divided in as many
cells as needed.
Cells are separated by lines starting with:
• #%% (standard cell separator)
• # %% (standard cell separator, when file has been edited with Eclipse)
• # <codecell> (IPython notebook cell separator)
Related plugins:
• Console
• File Explorer
• Find in files
16 Chapter 4. Editor
CHAPTER 5
IPython Console
Spyder’s IPython Console implements a full two-process IPython session where a lightweight front-end interface
connects to a full IPython kernel on the back end. Visit the IPython project website for full documentation of IPython’s
many features.
17
Spyder Documentation, Release 3
From the Consoles menu, Spyder can launch IPython Console instances that attach to kernels that are managed by
Spyder itself or it can connect to external kernels that are managed by IPython Qt Console sessions or the IPython
Notebook.
When “Connect to an existing kernel” is selected, Spyder prompts for the kernel connection file details:
IPython Consoles that are attached to kernels that were created by Spyder support the following features:
• Code completion
• Variable explorer with GUI-based editors for arrays, lists, dictionaries, strings, etc.
• Debugging with standard Python debugger (pdb): at each breakpoint the corresponding script is opened in the
Editor at the breakpoint line number
• User Module Deleter (see Console for more details)
IPython Consoles attached to external kernels support a smaller feature set:
• Code completion
• Debugging toolbar integration for launching the debugger and sending debugging step commands to the kernel.
Breakpoints must be set manually from the console command line.
When working with Python scripts interactively, one must keep in mind that Python import a module from its source
code (on disk) only when parsing the first corresponding import statement. During this first import, the byte code
is generated (.pyc file) if necessary and the imported module code object is cached in sys.modules. Then, when re-
importing the same module, this cached code object will be directly used even if the source code file (.py[w] file) has
changed meanwhile.
This behavior is sometimes unexpected when working with the Python interpreter in interactive mode, because one
must either always restart the interpreter or remove manually the .pyc files to be sure that changes made in imported
modules were taken into account.
The User Module Reloader (UMR) is a Spyder console’s exclusive feature that forces the Python interpreter to reload
modules completely when executing a Python script.
For example, when UMR is turned on, one may test complex applications within the same Python interpreter without
having to restart it every time (restart time may be relatively long when testing GUI-based applications).
Related plugins:
• Help
• Editor
• File Explorer
Debugging
21
Spyder Documentation, Release 3
22 Chapter 6. Debugging
CHAPTER 7
Console
The Console is where you may enter, interact with and visualize data, inside a command interpreter. All the commands
entered in the console are executed in a separate process, thus allowing the user to interrupt any process at any time.
23
Spyder Documentation, Release 3
24 Chapter 7. Console
CHAPTER 8
Variable Explorer
The variable explorer shows the namespace contents (i.e. all global object references) of the current console
The following screenshots show some interesting features such as editing lists, strings, dictionaries, NumPy arrays, or
25
Spyder Documentation, Release 3
27
Spyder Documentation, Release 3
Supported types
The variable explorer can’t show all types of objects. The ones currently supported are:
1. Pandas DataFrame, TimeSeries and DatetimeIndex objects
Help
The help plugin works together with the Console and the Editor: it shows automatically documentation available when
the user is instantiating a class or calling a function (pressing the left parenthesis key after a valid function or class
name triggers a call in the help pane).
Note that this automatic link may be disabled by pressing the “Lock” button (at the top right corner of the window).
Of course, one can use the documentation viewer directly by entering an object name in the editable combo box field,
or by selecting old documentation requests in the combo box.
Plain text mode:
31
Spyder Documentation, Release 3
32 Chapter 9. Help
Spyder Documentation, Release 3
Sometimes, when docstrings are not available or not sufficient to document the object, the documentation viewer can
show the source code (if available, i.e. if the object is pure Python):
Related plugins:
• Console
• Editor
33
Spyder Documentation, Release 3
34 Chapter 9. Help
CHAPTER 10
Projects
Spyder allows users to associate a given directory with a project. This has two main advantages:
1. Projects remember the list of open files in Editor. This permits to easily work on several coding efforts at the
same time.
2. The project’s path is added to the list of paths Python looks modules for, so that modules developed as part of a
project can be easily imported in any console.
To create a project, it is necessary to select the New Project entry from the Projects menu:
35
Spyder Documentation, Release 3
When a project is activated, the Project explorer pane is shown, which presents a tree view structure of the current
project
Through this pane it is possible to make several operations on the files that belong to project
Note: Projects are completely optional and not imposed on users, i.e. users can work without creating any project.
Spyder has limited integration with Git and Mercurial. Commit and browse commands are available by right-clicking
on relevant files that reside within an already initialized repository. This menu assume that certain commands are
available on the system path.
• For Mercurial repositories, TortoiseHG must be installed, and either thg or hgtk must be on the system path.
• For git repositories, the commands git and gitk must be on the system path. For Windows systems, the
Git for Windows package provides a convenient installer and the option to place common git commands on the
system path without creating conflicts with Windows system tools. The second option in the dialog below is
generally a safe approach.
The static code analysis tool may be used directly from the Editor, or by entering manually the Python module or
package path - i.e. it works either with .py (or .pyw) Python scripts or with whole Python packages (directories
containing an __init__.py script).
39
Spyder Documentation, Release 3
Related plugins:
• Editor
File Explorer
The file explorer pane is a file/directory browser allowing the user to open files with the internal editor or with the
appropriate application (Windows only).
41
Spyder Documentation, Release 3
Context menus may be used to run a script, open a terminal window or run a Windows explorer window (Windows
only):
Related plugins:
• IPython Console
• Editor
43
Spyder Documentation, Release 3
History log
The history log plugin collects command histories of Python/IPython interpreters or command windows.
Related plugins:
• Console
45
Spyder Documentation, Release 3
Find in files
The Find in Files plugin provides text search in whole directories or mercurial repositories (or even in PYTHONPATH)
with regular expression support for maximum search customization.
Related plugins:
• Editor
47
Spyder Documentation, Release 3
Online help
The online help plugin provides an internal web browser to explore dynamically generated Python documentation on
installed module, including your own modules (this documentation is provided by a pydoc server running in back-
ground).
Related plugins:
• Help
49
Spyder Documentation, Release 3
Internal Console
The Internal Console is dedicated to Spyder internal debugging or may be used as an embedded Python console in
your own application. All the commands entered in the internal console are executed in the same process as Spyder’s,
but the Internal Console may be executed in a separate thread (this is optional and for example this is not the case in
Spyder itself).
51
Spyder Documentation, Release 3