Python Installation and PyCharm Basics Joan Boone - - PowerPoint PPT Presentation

python installation and pycharm basics
SMART_READER_LITE
LIVE PREVIEW

Python Installation and PyCharm Basics Joan Boone - - PowerPoint PPT Presentation

INLS 560 Programming for Information Professionals Python Installation and PyCharm Basics Joan Boone jpboone@email.unc.edu Fall 2019 Download Python Interpreter Go to the Python downloads page and select the version for your operating system


slide-1
SLIDE 1

Python Installation and PyCharm Basics

Joan Boone

jpboone@email.unc.edu

Fall 2019

INLS 560

Programming for Information Professionals

slide-2
SLIDE 2

Download Python Interpreter

Go to the Python downloads page and select the version for your operating system (Windows, Mac, Linux)

slide-3
SLIDE 3

Install Python Interpreter

  • Select the downloaded file to start the installation.
  • Important! Remember the directory where Python is installed

– 'Install Now' picks a default directory – 'Customize installation' lets you specify the directory location

slide-4
SLIDE 4

If installation is successful, you should see this message

slide-5
SLIDE 5

Install PyCharm

Go to PyCharm download page and select the FREE Community Edition

slide-6
SLIDE 6

Install PyCharm

Run the installation program

slide-7
SLIDE 7

Install PyCharm

slide-8
SLIDE 8

Using PyCharm: Create a project

slide-9
SLIDE 9

Using PyCharm: Create a project

  • First, using File Explorer (Windows), or Finder (Mac), create a directory for

your projects, e.g., PyCharm_Projects

  • Name your project, e.g., INLS560
  • Specify the Python Interpreter you will use for your projects

Click to navigate to interpreter location

slide-10
SLIDE 10

Specify the Python interpreter to use

  • Select System Interpreter
  • Ensure that the Interpreter field refers to the Python interpreter

that you just installed. Click OK.

Click to navigate to interpreter location

slide-11
SLIDE 11

Using PyCharm: Create a project

Initial project structure for INLS560

  • Folder for your project
  • Folder with External Libraries
slide-12
SLIDE 12

Create a Python Program

  • Select INLS560, and

right-click for the context menu

  • Select New > Python

File, and enter HelloWorld as file name

slide-13
SLIDE 13

Create and run your program

  • Enter print(“Hello World!”) in the Editor
  • Select HelloWorld.py and select Run from context menu; or, select Run icon
  • Output is displayed in the Run Window in the bottom pane
slide-14
SLIDE 14

Default Window Layout

  • View > Tool Windows to modify layout
  • Window > Restore Default Layout to restore original, default layout

Project View Tool Window Editor

slide-15
SLIDE 15

Using PyCharm Debugger (OPTIONAL)

PyCharm documentation on Debugging

Steps to debug your program

  • Set breakpoints in your code. A breakpoint is associated with a

statement in your program. When your program runs in debug mode, the debugger will pause when the statement is reached so you can examine program data

– You set breakpoints by clicking in the left gutter area next to the

statement that you want to pause at when the program is running.

– You can toggle the breakpoint on/off by clicking the red circle in

the gutter area.

  • Run your program using the debugger
  • Examine program data in Variables pane
  • You can execute your program step-by-step (line at a time), or

resume execution so it runs until the next breakpoint

slide-16
SLIDE 16

Using the PyCharm Debugger

# 1 Set a breakpoint by clicking in left margin # 2 Run debugger # 3 Examine program variables # 4 Resume execution until the next breakpoint is reached 'Step Over' (or line by line) execution (optional)