Tutorial: Run Python With Spyder IDE

You might have read about applications like Python Tools for Visual Studio, PyCharm and Spyder IDE. These are Integrated Development Environments (IDE).

As part on our complete guide on Python for SEO, we will learn how to use Spyder IDE to run Python.

Become a Master in Python for SEO

This post is part of an entire series dedicated to Python for SEO and for Data Science.


What is Spyder IDE

You can think of a Spyder IDE as an application, like Microsoft Word, that helps you write in Python instead of writing in text format.

Note that if you have installed Python using Anaconda as we have seen earlier, Spyder IDE will be installed on your PC.

Understand The Spyder IDE Interface

Spyder IDE has three (3) main windows

  1. The Editor Window (for your scripts)
  2. The Object Inspector (for your files)
  3. The Console (for your IPython Shell)
Spyder IDE Interface

1. The Editor Window

The Editor Window is the place where you can write your Python scripts.

Python Scripts

2. The Object Inspector

The Object Inspector is where you can browse through your folders and information about modules, procedures and functions that your are using in your script

3. The Console

The Console is where you can access your IPython Shell and see the results of your scripts.

Start a Project in Spyder

First thing you need to do is to start a project.

Go to Project > New Project

Select the Path where you want to add your project.

This will become your work folder, where you will store and access files using Python.

Note: Make sure to use a local environment (your own PC, not a shared environment) if you plan to use command line. A server environment (ex: your company server folder or Google Drive) doesn’t allow you to work properly with command line.

Execute a Script in Spyder

To run a script in Spyder IDE, there are two options: use the command line option, use runfile in IPython.

Execute a Script Using the Command Line Options

Run > Configuration per file > Command line options

or

Hit Ctrl+F6

Run a Script Using Runfile

In [1]: runfile('C:/yourfolder/yourscript.py',args='one two three')