Installing Python and Core Tools

The following is the recommended setup for the UWPCE Python Certificate Program. It is not necessary to have exactly this same setup, but if you choose to use a different setup, we will be less able to support you if you need help.

Minimal Setup

Although it is OK to use different tools, there are some requirements to successfully do the work the program requires:

  1. cPython version 3.9 or greater

  2. A way to edit Python files (Programmers Text Editor)

  3. A way to run your code – command line, IDE, etc.

  4. A way to use the “git” source code version control system

You can be successful in the program as long as you have the above. If you don’t already have a setup that fulfills those requirements: read on.

Platforms

Python is a very platform independent system. It can run on all major operating systems, including micro controllers even. It is most commonly used in production on Windows, Linux or macOS systems.

For this program we feel it is best for students to work in an environment in which they are comfortable, and which they will ultimately use to do production work.

We have included instructions for Windows, Linux and macOS systems – any of these are fine.

Python Itself

Python is a “byte compiled, interpreted” language. What this means to you is that you need a Python interpreter to run your Python code. It also means that that is all you need – write some code, and run it with Python. That’s it.

There are a number of different Python interpreters (or run-time environments) available:

  • cPython

  • PyPy

  • Jython

  • Iron Python

  • MicroPython

These each have their own special uses. For example, for interaction with the Java VM or Microsoft CLR, or running on micro controllers. But most production Python is run with the cPython interpreter, and most people mean cPython when they say “Python”.

For this program, you will need cPython version 3.9 or greater, installed and running so that when you type “python” at your command line, it starts up.

cPython itself is available from a number of sources, or “distributions”. We recommend the version available from python.org.

Python is also available as part of the Anaconda data analysis environment, as well as a few other sources. These Python distributions will work fine for this class, but when we get to advanced topics like virtual environments, there are some differences – and you will be responsible for adapting to these differences.

Your Development Environment

There are four elements to your environment when working with Python:

  • The Command Line

  • The Interpreter

  • The Editor

  • The source code version control system

Some folks use an Integrated Development Environment (IDE), such as PyCharm, which combines some or all of these functions. For this class, we don’t recommend using an IDE, because while it can make some things easier, it can also hide things that will be good for you to understand. But it’s your call – you should use tools you are comfortable with.

Minimal Requirements

In order to be productive in this program, you need to be able to do the following:

  • Manipulate files and write and save Python code in files. You really, really want a “real” programmer’s editor (not Notepad! or TextEdit!) for this.

  • Run your code with Python 3.9 or greater

  • Run the iPython interactive interpreter

  • Install new packages with pip

  • Use the git source code management system (with GitHub Classroom)

If you are not set up and comfortable with doing all that, read and follow these instructions:

Setup Details

Then come back and follow the rest of this review.

The Command Line (CLI)

Having some familiarity with the command line is important.

Familiarity with basic use of the command line is a prerequisite for the program, so we won’t cover this much in class. If you are not comfortable with the command line, please spend some time to learn on your own. We have some resources here: Command Line Basics.

We suggest running through the CLI tutorial at “learn code the hard way”:

Command Line Crash Course

Or, for Linux and macOS users:

Linux command line for you and me!

Windows

Most of the demos in lessons will be done using the “zsh” command line shell on macOS. This is, for our purposes, identical to the bash shell on Linux.

Windows provides the DOS Command Prompt, which is OK, but pretty old and limited, or “Power Shell” – a more modern, powerful, flexible command shell.

If you are comfortable with either of these – go for it.

If not, you can use the “Git Bash” shell – which is much like the zsh shell on macOS and Linux. See: Terminal

Or, on Windows 10 or Windows 11, look into the “Bash shell for Windows” otherwise known as the “Linux Subsystem for Windows” or “WSL” – more info here: Using Windows Bash for Python Development

macOS

macOS comes out of the box with the zsh command line. You can access it by running the “Terminal” application, which you can find under:

Applications => Utilities => Terminal.app

Place it into the dock for easy access.

The Terminal app can be interfaced with the Finder, making it easy to open it up with the working directory set to the current folder in the finder. On macOS, you may have a “New Terminal at Folder” right-click (or command click aka “secondary click”) menu item already – try it! If not, you can turn it on by following these instructions:

Head into System Settings and select Keyboard => Shortcuts => Services. Find “New Terminal at Folder” in the settings and click the box. Now, when you’re in Finder, just right-click a folder and you’re shown the open to open Terminal under the Services sub-menu. When you do, it’ll start right in the folder you’re in.

Linux

Whether you use the KDE or GNOME Desktop (or anything else), there should be a way to open a shell from the file manager. Find it, it’s very handy. Unfortunately, Linux has too many variations to go into any detail here on how to use it.

The Python Interpreter

If you haven’t already, install everything you need following these instructions: Setup Details

Python comes with a built-in interpreter.

You see it when you type python at the command line:

$ python
Python 3.12.5 (main, Aug  9 2024, 08:49:33) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

That last thing you see, >>>, is the “Python prompt”.

This is where you can type code.

Python in the Interpreter

Try it out:

>>> print("hello world!")
hello world!
>>> 4 + 5
9
>>> 2 ** 8 - 1
255
>>> print ("one string" + " plus another")
one string plus another
>>>

To get out of the interpreter, you can type:

exit()

Or hit ctrl+D on Linux and macOS or ctrl+Z On Windows.

Tools in the Interpreter

When you are in the interpreter, there are a number of tools available to you.

There is a help system:

>>> help(str)
Help on class str in module __builtin__:

class str(basestring)
 |  str(object='') -> string
 |
 |  Return a nice string representation of the object.
 |  If the argument is a string, the return value is the same object.
 ...

You can type q to exit the help viewer.

You can also use the dir builtin to find out about the attributes of a given object:

>>> bob = "this is a string"
>>> dir(bob)
['__add__', '__class__', '__contains__', '__delattr__',
 '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
 '__getitem__', '__getnewargs__', '__getslice__', '__gt__',
 ...
 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines',
 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper',
 'zfill']
>>> help(bob.rpartition)

This allows you quite a bit of latitude in exploring what Python is.

Advanced Interpreters

In addition to the built-in interpreter, there are several more advanced interpreters available to you.

We’ll be using one in this course called iPython.

Some information about iPython can be found here: iPython Interpreter

The Editor

Typing code in an interpreter is great for exploring.

But for anything “real”, you’ll want to save the work you are doing in a more permanent fashion.

This is where an editor fits in.

Text Editors Only

Any good programmer’s text editor will do.

MS Word is not a text editor.

Nor is TextEdit on a Mac.

Notepad on Windows is a text editor – but a poor one.

You need a real “Programmer’s Text Editor”

A text editor saves only what it shows you, with no special formatting characters hidden behind the scenes.

Minimum Requirements

At a minimum, your editor should have:

  • Syntax Colorization

  • Automatic Indentation

In addition, great features to add include:

  • Tab completion

  • Code linting

  • Jump-to-definition

Have an editor that does all this? Feel free to use it.

If not, we recommend “Sublime Text” which works on Windows and macOS:

http://www.sublimetext.com/

Turning Sublime Text Into a Lightweight Python IDE

“Visual Studio Code” or “VS Code” is another good open source option that also works on Windows, Linux, and macOS.

https://code.visualstudio.com/download

Using Visual Studio Code as a Python IDE

And, of course, vim or Emacs on Linux and macOS, if you are familiar with one of those. They are fine choices but can be confusing to someone who is not familiar with their quirks.

Why No Full IDE?

An IDE does not give you much that you can’t get with a good editor plus a good interpreter.

An IDE often weighs a great deal.

Setting up IDEs to work with different projects can be challenging and time-consuming.

Particularly when you are first learning, you don’t want too much done for you.

Why an IDE?

That said … you may want to go get the educational edition of PyCharm:

https://www.jetbrains.com/pycharm-edu/

Which a lot of people like a lot.

Visual Studo Code from Microsoft can be made into a pretty full featured IDE as well if you want it to be.

But do make sure, when you set up and IDE, that you know what its doing when you click “run”, and that it is using the version of Python that you expect. (cPython 3.9 in this case)

Version Control System

While not strictly necessary to develop code, it is a very, very, good idea to manage your code in a Version Control System.

This is such a critical software development practice that we use it in the program for you to mange your projects and turn in assignments (via GitHub classroom), so that you can gain familiarity with the practice.

Git

Git is an open-source version control system that has become an industry standard – very widely used in both commercial and open-source development.

We will be using Git and the web service GitHub for collaboration in this program.

Make sure you are set up to use git on your machine. If you have using a command line client, you should be able to type:

git --version

And get something like this as a response:

git version 2.17.2 (Apple Git-81)

Am I ready to go?

To see if you have Python ready to start class, try this:

Testing Your Setup