running python for rcs...

18
Running Python for RCS Tutorials Fall 2020 Research Computing Services IS & T

Upload: others

Post on 10-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Running Python for RCS Tutorials

Fall 2020

Research Computing Services

IS & T

Page 2: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Table of Contents

For any of the Python tutorials follow the instructions on slides 3-6.

Refer to the slides in this table for specific tutorials:

Tutorial Also refer to slides…

Introduction to Python (both parts) 7-9

Introduction to pandas Data Visualization in PythonIntroduction to Python scikit-learn

11-15

Numerical PythonPython OptimizationPython Parallelization

7-9 and 16-18

Page 3: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Getting Started

• The downloads for the Python tutorials are located at:

http://rcs.bu.edu/examples/python/tutorials/

• That link has two files for downloading.• One is a copy of this presentation.• The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

presentations and sample Python files for all of the available Python tutorials.• This is for everyone, regardless of the specific Python tutorial you are taking. • This ZIP archive must be extracted to a folder to use it with the Python software.

• Windows: right-click the ZIP file and choose “Extract All”• OSX: double-click the ZIP file• Linux: use the unzip utility from a terminal: unzip rcs_py_tutorials_2020.zip

Page 4: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Installing Python

• The Python programming language can be easily used on common systems (Windows, Macintosh OSX, and Linux) by installing the Anaconda Navigator software• This is a pre-packaged collection of hundreds of libraries and a variety of development tools

with the Python language software.

• The installation must be completed before you start the tutorial due to the size of the download and the time to run it.

• Start by downloading the Python 3.8 installer for your computer and running it.

https://www.anaconda.com/products/individual

Page 5: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Windows Install Notes

• The 64-bit version of the installer is recommended.

• When prompted during the install, choose the “Just Me” option.

• This avoids file permission related issues if you update the Anaconda installation.

Page 6: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

First steps

• Locate and run the Anaconda Navigator program that was installed.

• Refer to the table of contents on slide 2 to see where to look next.

Example: On Windows 10 use the search feature (magnifying glass icon in the bottom left) and search for anaconda navigator

Page 7: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

SpyderA text-oriented development environment for Python.

These slides show you how to open the Spyder software and give a reference to understanding its interface.

Page 8: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Spyder

Click

Choose your Anaconda Environment*Use base (root) for RCS Tutorials*

Page 9: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Text Editor(Write Python Scripts here)

Python Console(Run Individual Python Commands here)

Variable Explorer(View Variables loaded in Memory here)

Page 10: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Current Working Directory*Set to Directory with RCS Tutorial Example Python scripts*

Click to Run Python Script

Click to Run Debugger Tools on Python Script

Page 11: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Jupyter NotebookA graphical browser-based development environment for Python.

These slides show you how to open the Jupyter Notebook software and give a reference to understanding its interface.

Page 12: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Click

Choose your Anaconda Environment*Use base (root) for RCS Tutorials*

Page 13: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

• A tab will open on your web browser

• You are working locally with the Jupyter software running Python on your computer.

Click

Page 14: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

• A new tab will open

• This is your working/coding interface

A cell that run your python code

Click to run the code in the highlighted cell

Page 15: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Try to import packages needed for the tutorialsBecomes a number if the code

successfully run

• Please make sure everything works fine up to this point before the tutorials.

Page 16: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Extra Libraries for the Tutorials

• The tutorials need a few extra libraries to be installed.

• To install them:• First close Spyder or Jupyter if they’re running.• Open Anaconda Navigator • Follow the instructions on the next few slides.

• These should be completed before attending the Numerical and Scientific Computing in Python and Optimizing Python tutorials.

• If you don’t get them installed, please still attend the tutorial, but be aware that some of the example code won’t run in your Anaconda setup without the libraries.

Page 17: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

1) Click Environments

2) Click the button and choose Open Terminal

Page 18: Running Python for RCS Tutorialsrcs.bu.edu/examples/python/tutorials/Python_for_RCS_tutorials.pdf · •The other, rcs_py_tutorials_2020.zip, is a ZIP archive containing all of the

Example of the Windows terminal

In the terminal window that opens enter the following commands:

conda update -y --all

conda install -y line_profiler memory_profiler

conda install -y opencv libopencv py-opencv

conda install -y spyder-line-profiler spyder-memory-profiler

This will update the Python libraries installed with Anaconda and install the libraries needed for the tutorials. This may take 30 minutes or more to complete, depending on the speed of your computer and Internet connection.