Python IDE – Download IDE Python – Download Python

If you are just starting out, the staff recommends that you download Anaconda and use its Integrated Development Environment. But you are welcome to use any other IDE!

NOTE: Latest installation instruction can also be found from the official Anaconda website. We will try to keep this as up-to-date as possible but the instructions here may differ from what you actually experience. The grader uses Python version 3.5. Newer versions are ok to use for the purposes of this course.

This will cover how to set up Python and introduce you to Spyder, the Python development environment we will be using throughout this course. It will also show you how to check that the Python library packages matplotlib and numpy were successfully installed. They will be used later in this class to work with plots.

Downloading the Python Installer

To download the free “Anaconda” Python distribution created by Continuum Analytics:

  1. Visit the download page for Continuum Analytics.
    NOTE: the installer we’ll be downloading and installing is larger than the average file, because it contains Python, associated packages, a code editor, and some other toys. It may take 15-20 minutes in total to download and install when executing the commands.
  2. You will be downloading the Python 3 version (any version 3.5 or later is good). If you download Python 2.7, your code may be incorrect to our graders.
  3. Windows Operating System: Scroll to the “Anaconda for Windows” section. Look in the column with Python 3.5. There are two versions of the installer, one for 32-bit Windows, and one for 64-bit Windows. Microsoft provides instructions here to determine (relatively easily) if you have a 32 or 64-bit setup. If you are running 32-bit Windows, be sure that you select the 32-bit version, and if you are running 64-bit Windows, you can download either version.
    python for windows
  4. Macintosh Operating System: Scroll to the “Anaconda for OS X” section. Look in the column with Python 3.5. There is only one version of the installer: the 64-bit version. Continuum does not offer a 32-bit installer for Macintosh, since Macs post-2011 are 64-bit only (and post-2007 are 64-bit compatible).
  5. Linux Operating Systems: Scroll to the “Anaconda for Linux” section. Look in the column with Python 3.5. You can look here for how to determine your version 32-bit or 64-bit.

Installing Python and Spyder

  1. To install Python after downloading the graphical installer, double click the .exe (Windows) or .pkg (Mac) file and follow the instructions on the screen. There are some additional notes and comments on installing/uninstalling Python on Continuum’s website here.
  2. Note that Continuum’s Python distribution should (per their quick start guide) install cleanly into a single directory, should not require Administrator or root privileges, and should not affect other Python installs on your system (if you have any), or interfere with OSX Frameworks. Let us know in the forum if you’re having any issues, so that others can learn along with you.
  3. When installing Anaconda, a pop-up menu may ask whether or not to “Add Anaconda to my PATH environment variable”, and “Register Anaconda as my default Python 3.5.” We suggest accepting both options for the purposes of this class.
  4. The installation will take about 15 minutes. Click Finish to close the window when done.

Starting Spyder, a code editor

When you download and install the Anaconda distribution of Python, you are getting several tools related to Python development. One of the tools is Spyder (Scientific Python Development Environment), an integrated development environment useful for writing, running, and debugging code. There are two primary ways to access the tools and open Spyder:

  1. Windows Only: The Anaconda folder from the Start menu.
  2. The Anaconda Navigator shortcut icon.

    Both should open the Anaconda Navigator. Click here to read more about its features. We will only be using one app from Anaconda in this class: Spyder. Click the blue “Launch” button by “spyder” to launch Spyder. It should take a moment to load and may appear to pause for a minute or two.

Configuring Spyder

Before using Spyder, we recommend configuring Spyder to use the “Clear variables before execution” option. This will help prevent future debugging issues due to old variables being kept between executions of your code. This feature can be found in the preferences (accessed by Python -> preferences on Mac, Tools -> preferences on Windows and Linux):

clear var

Once in preferences, choose the “run” category, and check the “Clear variables before execution” setting under “General Settings”:

clear var

Spyder Application Overview

Opening the Spyder application should present you with the following window (screenshot is from Mac OS X, but are similar in Windows and Linux). This window contains two commonly used parts, among others:

  • Code Editor that lets you create and edit existing Python source files [YELLOW CIRCLE 1]
  • IPython interpreter pane, which gives you access to the Python interactive mode [YELLOW CIRCLE 2]During the following discussion of Spyder’s features, you should start Spyder and try to replicate the screenshots.

Using the IPython prompt:

  1. The IPython prompt looks something like this: “In [1]:”, and can be used to run Python code. You can type Python code directly into this prompt, and pressing enter executes the code fragment. The result of the computation is preceded by the words “Out []”.
  2. Try typing the following after the prompt and pressing the enter key:
Using the IPython prompt – examples and exercises:

Addition (+), subtraction (-), multiplication (*), division (/), modulo (%) and power (**) operators are built into the Python language. This means you can use them right away. If you want to use a square root in your calculation, you can either raise something to the power of 0.5 or you can import the math module. Do not worry about what it means right now, we will cover this later during the course. Below are two examples of square root calculation:

The math module allows you to do a number of useful operations:

Exercises: Use the IPython prompt to calculate:
(these are just for practice, solutions will not be graded or collected)

  • 6+4*10
  • (6+4)*10
    (Compare this to the previous one, and note that Python uses parentheses just like you would in normal math to determine order of operations!)
  • 23.0 to the 5th power
  • Positive root of the following equation: 34*x^2 + 68*x – 510 = 0
    Recall: given a*x^2 + b*x + c = 0,
    then x = (-b +sqrt(b*b – 4*a*c))/(2*a)
  • import math
    math.cos(3.4)**2+math.sin(3.4)**2

To create, save, and run a file

Creating the file

  1. In Spyder’s File menu, select “New file”.
  2. In the new file, type the following:

Saving the file

  1. Saving your files in a location specific for this course can aid in organization. To do that, first create a directory (or folder) for your 6.00.1x material, with an appropriate name.
  2. Now you can save your “hello world” file in the new folder that you just created.
  3. From the Spyder File menu, click “Save As” and then navigate to your course folder before typing a name for this file, e.g., “hello”. Make sure that you’re saving the file as type Python (see below for images on Mac and PC).
  4. Click the Save button

Running the file

  1. From within Spyder, go to the “Run” menu, click on “Run”.
  2. You should see two parts to the output in the IPython console. First, The runfile(…) line shows you the filepath on your computer for the file you just ran. Second, the output of the file, “Hello world”, should appear. If you get an invalid alias error, do the following:
      1. Open Spyder
      2. Type the following command into the IPython console: !conda install -y ipython=7.7.0
      3. After a couple of minutes, the installation should complete
      4. Close Spyder and reopen it
  3. Go back to the Code Editor and add the following line: print(‘I like 6.00.1x!’)
  4. Select “Run File” again (you can also use the green triangular Run button on the toolbar or the shortcut F5), and observe the change in result.
  5. Close your test file by clicking the X in its filename tab.
  6. Now reopen your test file by double-clicking its name in the File menu’s “Open recent” option.
  7. Congratulations – your Python environment has been installed, and you now know how to enter expressions in Python and how to save, run, and open files!
  8. For additional help on Spyder, go the Help menu within Spyder, and select the “Spyder tutorial” option.

Installing and Testing Matplotlib and Numpy

To work with plots, you will need these Python library packages: matplotlib and numpy. You will not need these packages until the end of the course but we encourage you to download them early.

If you’re using Anaconda Python, your system should already have numpy and matplotlib installed. Start Spyder and type “import numpy” and “import matplotlib” into the prompts.

If no errors show up, you already have them installed. If errors show up, reach out via the forum!

Share by codehay.pro

Download Python – IDE Python

Nicholas Andrew

Nicholas Andrew

My name's Quang Trường, from Ha Noi My favorite: Create Website, Software,... Phone: 0862020654 Mail: admin@codehay.pro

2 Replies to “Python IDE – Download IDE Python – Download Python

Leave a Reply

Your email address will not be published. Required fields are marked *