Getting Started
Last updated on 2023-05-08 | Edit this page
Overview
Questions
- How do I use the Spyder IDE?
- How can I run Python programs?
Objectives
- Learners can launch the Spyder IDE
- Learners are able to use the IPython console to interact with Python
- Learners are able to write code in the Spyder editor and run this code
- Learners are able to save their code in a *.py file
- Learners can use the different buttons and panels needed in the Spyder IDE
Use the Spyder IDE for editing and running Python.
-
The Anaconda package manager is an automated way to install the Spyder IDE.
- See the setup instructions for Anaconda installation instructions.
It also installs all the extra libraries it needs to run.
-
Once you have installed Python and the Spyder IDE requirements, open a shell and type:
This will start The Spyder IDE.
This environment has several useful tools we can use, which you can see in different panels in the Spyder IDE. We will look into some of them.
You can change the positions and sizes of these panels to your preference, as you get to know them.
Different ways of interacting with Python using Spyder
- On the left, filling half of the screen is the editor. Here you can write and edit code, which can then be saved in a file (usually with a .py extension). We can run the code we wrote here by pressing the green ‘play’ button on top or press F5 on your keyboard.
- On the bottom right, we find the IPython console. This is were we can talk directly to Python. It will interpret what you have typed directly when you press Enter.
Python in the console
Python in the editor
The large panel on the left probably has some text in it that looks like this:
"""
Spyder Editor
This is a temporary script file.
"""
Write the following line below these lines and press run (the green ‘play’ button or f5). A window might pop up asking you to specify the run settings, leave the settings as they are and press ‘Run’. What happens?
- Code written in the editor can be saved, like any other file.