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 (Windows, Mac, Linux)
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
If installation is successful, you should see this message
Install PyCharm Go to PyCharm download page and select the FREE Community Edition
Install PyCharm Run the installation program
Install PyCharm
Using PyCharm: Create a project
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
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
Using PyCharm: Create a project Initial project structure for INLS560 ● Folder for your project ● Folder with External Libraries
Create a Python Program Select INLS560 , and ● right-click for the context menu Select New > Python ● File, and enter HelloWorld as file name
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 ●
Default Window Layout Project Editor View Tool Window View > Tool Windows to modify layout ● Window > Restore Default Layout to restore original, default layout ●
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
Using the PyCharm Debugger # 2 Run debugger # 1 Set a breakpoint by clicking in left margin # 4 Resume execution # 3 until the next Examine program breakpoint is variables reached 'Step Over' (or line by line) execution (optional)
Recommend
More recommend