Installing Python and VS Code

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

1) Overview

This page guides you through installing Python on your computer and setting up an integrated development environment (IDE) in which to run Python code. There are separate instructions below for Windows and macOS.

The overall procedure is as follows:

  1. Set up a folder for your 6.100 psets.
  2. Install the base Python interpreter.
  3. Install the Visual Studio Code (VS Code) editor.
  4. Install the Python extension for VS Code.
  5. Install additional Python packages that we will use in this course.

Please follow the instructions carefully and exactly! Previous students have run into problems when they skipped steps that they thought weren't important. If you are unsure about what any of the instructions mean, ask a TA or LA during office hours.

Before starting, make sure your operating system is up-to-date. The instructions below have been tested with Windows 11, version 23H2 and macOS Sonoma, version 14.

2) Windows

2.1) Set up 6.100 folder

  1. In File Explorer, create a folder called 6.100A somewhere on your system. (Or call it 6.100L or 6.100B as appropriate.)

  2. Download the 1_pset0.zip file from the top of the Pset 0 page. This file contains a compressed ps0 folder. In File Explorer, right-click the file and click Extract All... to unzip it. Then move the unzipped ps0 folder into 6.100A. The folder structure should look like this:

    6.100A
    |---ps0
        |---ps0.py
        |---test_packages.py
        |---test_python.py
    
    • To clearly distinguish between zip files versus folders in File Explorer, you may need to enable File name extensions under ViewShow.

2.2) Install the base Python interpreter

  1. Download the Python installer executable (big yellow button) from https://www.python.org/downloads/.

  2. In File Explorer, double-click the executable file to run it. Click through any security warnings. When the setup window appears, do not select any checkboxes at the bottom. Just click Install Now, which accepts all the default options.

  3. At the end, the installer may ask you to Disable path length limit. Click this if you see it, and click through the security warning.

  4. To verify the installation, open the Command Prompt from the Start menu. This is a text-based interface for running programs, and the native Windows prompt ends with a single >.

    In this interface, type py -3 (note the space) and press Enter. This launches the Python program in interactive mode, which has its own >>> prompt.

    C:\Users\bob>py -3
    Python 3.12.5 (tags/v3.12.5:ff3bc82, Aug  6 2024, 20:45:27) [MSC v.1940 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
  5. To exit Python, press Ctrl+Z and then Enter. This should take you back to the native Windows prompt. To exit that, type exit and press Enter.

2.3) Install VS Code

  1. Download the VS Code installer executable (big blue button) from https://code.visualstudio.com/.

  2. Run the executable file, and click through any security warnings. Accept all the default options as you click through the setup.

  3. When you click Finish, the VS Code program should launch with a Welcome tab and potentially a Release Notes tab. Ignore and close any recommendations that pop up in the bottom right.

  4. Open the EXPLORER pane from its icon (first one) in the top left. Click Open Folder, navigate to and select your 6.100A folder, and click Open. When the security warning about trust pops up, click Yes, I trust the authors.

  5. From the top menu bar, go to FilesPreferencesSettings, and a Settings tab will appear. Under the User category, go to Text EditorFiles, and check the boxes for the following options. (They are listed in alphabetical order.)

    • Insert Final Newline
    • Trim Final Newlines
    • Trim Trailing Whitespace

    Close the Settings tab when done.

2.4) Install the Python extension for VS Code

  1. In VS Code, open the EXTENSIONS pane from its icon (fifth one) in the top left.

  2. You can either search for the Python extension from Microsoft, or it may already appear in the list of POPULAR extensions.

  3. Click on the tile result, which opens an Extension: Python tab. Make sure it's the official extension from Microsoft, and click Install.

  4. When installation completes, you should see the Python extension tile under the INSTALLED category. There may be a couple other Python-related extensions from Microsoft as well. Now close VS Code and open it again from the Start menu.

  5. Go to FilesPreferencesSettings to open a Settings tab again. Navigate to ExtensionsPython, and enable the setting Terminal: Execute in File Dir. Do not skip this step!

  6. Open the EXPLORER pane again, and navigate to your ps0 folder. Double-click test_python.py to open it in a tab. At the very bottom right, you should see the word Python along with the version number of your Python installation. When you click the version number, a drop-down from the top center should list exactly which executable file is being used as the Python interpreter.


  7. Press Esc to close the drop-down, and click the Run Python File play button in the top right. This should open a TERMINAL pane at the bottom with the execution of the test_python.py file.

  8. Click in the TERMINAL pane, type your response to its query, and press Enter. The program should repeat what you typed.

  9. At the top-right of the TERMINAL pane, click the Kill Terminal trash button to close it.

2.5) Install Python packages

  1. Open a new terminal in VS Code by going to TerminalNew Terminal in the top menu bar.

  2. In the terminal, type each of the following commands, followed by Enter to execute. Do not type the >; that just indicates the prompt.

    > py -3 -m pip install numpy
    > py -3 -m pip install matplotlib
    > py -3 -m pip install seaborn
    > py -3 -m pip install scikit-learn
    

    Ignore any warnings in the output about a certain directory not being on PATH.

    Note: After the first command, you don’t have to completely retype the subsequent commands. By pressing the Up arrow while in the terminal, you can access your command history, and just change the package name at the end.

  3. Kill the terminal when finished.

  4. Open the file test_packages.py, and run it by clicking the play button. After a moment, you should see a plot of earthquake magnitudes over time.

  5. Close the plot window, then kill the terminal.

That's it! For future psets and lecture code downloads, just unzip them into the 6.100A folder, and press the play button for any file you wish to run.

3) macOS

3.1) Set up 6.100 folder

  1. In Finder, create a folder called 6.100A somewhere on your system. (Or call it 6.100L or 6.100B as appropriate.)

  2. Download the 1_pset0.zip file from the top of the Pset 0 page. This file contains a compressed ps0 folder. In Finder, double-click the file to unzip it. Then move the unzipped ps0 folder into 6.100A. The folder structure should look like this:

    6.100A
    |---ps0
        |---ps0.py
        |---test_packages.py
        |---test_python.py
    

3.2) Install the base Python interpreter

  1. Download the Python installer package (big yellow button) from https://www.python.org/downloads/.

  2. In Finder, double-click the package file to run it. Click through each page in the installer. At the Installation Type step, just directly click Install and enter your password to continue; don't click Customize or anything similar to that.

  3. When the installer finishes, a new Finder window will pop up. Click Close in the installer window and then Move to Trash.

  4. Double-click Install Certificates.command in the Finder window. A Terminal window will pop up and run something briefly. Close both the Terminal and Finder windows.

  5. To verify the installation, open a new Terminal window. This is a text-based interface for running programs, and the native macOS prompt ends with a single %.

    • If you have an older Mac, even with the latest macOS, the prompt may end with $ instead of %.

    In this interface, type python3 and press Enter. This launches the Python program in interactive mode, which has its own >>> prompt.

    bob@macbook ~ % python3
    Python 3.12.5 (v3.12.5:ff3bc82f7c9, Aug  7 2024, 05:32:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
  6. To exit Python, press Control+D. This should take you back to the native macOS prompt. To exit that, press Control+D again, and then close the Terminal window.

3.3) Install VS Code

  1. Download the VS Code installer zip file (big blue button) from https://code.visualstudio.com/.

  2. Unzip the file, which produces another file Visual Studio Code.app. Drag the file to the Applications folder in the left-side navigation under Favorites.

    • If you don't see the Applications folder there, navigate to it via GoApplications in the menu bar. Then open another Finder window, and drag the app file across windows into Applications.
  3. Double-click the app file to launch it, and click through the security warning. VS Code should launch with a Welcome tab and potentially a Release Notes tab. Ignore and close any recommendations that pop up in the bottom right.

  4. Open the EXPLORER pane from its icon (first one) in the top left. Click Open Folder, navigate to and select your 6.100A folder, and click Open. When the security warning about trust pops up, click Yes, I trust the authors.

  5. From the menu bar, go to CodeSettings... (or Preferences on older Macs) → Settings, and a Settings tab will appear. Under the User category, go to Text EditorFiles, and check the boxes for the following options. (They are listed in alphabetical order.)

    • Insert Final Newline
    • Trim Final Newlines
    • Trim Trailing Whitespace

    Close the Settings tab when done.

3.4) Install the Python extension for VS Code

  1. In VS Code, open the EXTENSIONS pane from its icon (fifth one) in the top left.

  2. You can either search for the Python extension from Microsoft, or it may already appear in the list of POPULAR extensions.

  3. Click on the tile result, which opens an Extension: Python tab. Make sure it's the official extension from Microsoft, and click Install.

  4. When installation completes, you should see the Python extension tile under the INSTALLED category. There may be a couple other Python-related extensions from Microsoft as well. Now make sure to quit (and not just close) VS Code, and launch it again.

  5. Go to CodeSettings... (or Preferences) → Settings to open a Settings tab again. Navigate to ExtensionsPython, and enable the setting Terminal: Execute in File Dir. Do not skip this step!

  6. Open the EXPLORER pane again, and navigate to your ps0 folder. Double click test_python.py to open it in a tab. At the very bottom right, you should see the word Python along with the version number of your Python installation. When you click the version number, a drop-down from the top center should list exactly which binary file is being used as the Python interpreter.


    A small window about "python3" may pop up, asking to install the command line developer tools. Click Cancel, not Install.

  7. Press Esc to close the drop-down, and click the Run Python File play button in the top right. This should open a TERMINAL pane at the bottom with the execution of the test_python.py file.

  8. Click in the TERMINAL pane, type your response to its query, and press Enter. The program should repeat what you typed.

  9. At the top-right of the TERMINAL pane, click the Kill Terminal trash button to close it.

3.5) Install Python packages

  1. Open a new terminal in VS Code by going to TerminalNew Terminal in the menu bar.

  2. In the terminal, type each of the following commands, followed by Enter to execute. Do not type the %; that just indicates the prompt.

    % python3 -m pip install numpy
    % python3 -m pip install matplotlib
    % python3 -m pip install seaborn
    % python3 -m pip install scikit-learn
    

    Ignore any warnings in the output about a certain directory not being on PATH.

    Note: After the first command, you don’t have to completely retype the subsequent commands. By pressing the Up arrow while in the terminal, you can access your command history, and just change the package name at the end.

  3. Kill the terminal when finished.

  4. Open the file test_packages.py, and run it by clicking the play button. After a moment, you should see a plot of earthquake magnitudes over time.

  5. Close the plot window, then kill the terminal.

That's it! For future psets and lecture code downloads, just unzip them into your 6.100A folder, and press the play button for any file you wish to run.