Starting and Using Spyder

This page provides operating system-specific advice for starting and the basics of using Spyder, as mentioned in Section 3.2.5 of the textbook. Details on the Spyder debugger are here.

Starting Spyder Using Anaconda Navigator

The easiest way to start Spyder is from Anaconda Navigator. The documentation for Navigator gives details (including how to start the Navigator app on different operating systems), but the main steps are:

  • Open the Anaconda Navigator app.
  • In the Home tab, find the Spyder tile and click “Launch”.
  • Once Spyder is started, we can create a new code file or open an existing code file.

    Starting Spyder from a Terminal Window or Via the Desktop App

    Here are various ways of doing so, depending on our operating system:

    • Linux: In a terminal window type spyder.
    • Mac OSX: Same as for Linux.
    • Windows: Search for the “Spyder” desktop app and start is via the menu result.

    The location of the Spyder application is the same place as the python application. See the page on starting and using the Python interpreter in a terminal window for the discussion of how to find the full path to those applications for various operating systems.

    Opening an Existing Python Code File in Spyder

    While we can open a new Python code file in Spyder from the command-line of a terminal window (by typing spyder file.py, where file.py is replaced with the name of your code file), the easiest way is to open an existing file is by choosing “File” → “Open…”.

    Below is the result of opening the myscript3.py file (shown in Figure 3.6 in the textbook) in Spyder:

    In the above example, Spyder defaults to putting us into an IPython interpreter interface (the lower right-hand pane). This behaves very similarly to the “three greater than signs” Python interpreter, except it has the In [], etc. prompts similar to a Jupyter notebook.

    The menu command “Run → Run” or the green arrow button will run the Python code file with the results showing in the interpreter pane:

    We can also type code to execute in the IPython interpreter interface, apart from the code from the left pane that was run.

    If the script, for some reason, freezes while running, or we need to manually stop the script from running, type “Ctrl-c” while in the console (IPython or regular Python interpreter). More details about the Spyder IDE are available online at https://www.spyder-ide.org/.

    Managing the Current Working Directory Using a GUI in Spyder

    This section continues the textbook’s discussion in Section 10.2.1, for the case of using a GUI in Spyder to manage the current working directory. If we are using Spyder, there is a block of buttons in the upper right corner of the console:

    The leftmost field (the combo box listing a directory) shows the current working directory for new interpreter (console) sessions. We can select amongst past working directories, and when we change the value in the box, that value becomes the current working directory. The center button (the folder button) brings up a dialog window that enables us to select another directory for the leftmost combo box. The rightmost button (the up arrow button) changes the combo box to the parent of whatever directory currently is selected in the box.