So let's demystify the Python runtime environment a bit.
Up until now, you've been learning
how the code itself works.
That is, how the Python interpreter,
which is a computational process
running on your computer,
considers the commands you give it, which are loops,
control structures, variables, functions,
and how it executes
the underlying code on hardware such as the processor,
video card, and memory of your computer,
to create some experience for the user.
In much of this course,
you've been using a web-based simulation environment,
Runestone, to create these experiences.
With Jupyter though, we'll be using
an environment that is more traditional.
A key aspect of this traditional environment
are the installation files for Python itself.
Let's take a look. I'm going to open up a new terminal.
Don't worry if this seems unfamiliar to you,
we won't be using the terminal much in this course.
I just want to help you explore the Jupyter system a bit.
You'll notice that there are a bunch of
characters when we open up the terminal.
The first set of characters are username.
You could ignore this.
It should be the same Jovyan for all Coursera users.
Then there's an at sign,
and the next set of characters, are the machine name.
Again, the machine name is just
auto-generated by the Coursera system,
and isn't really relevant for our discussion right now.
Finally, the rest of the string is
the current path or the location that we're working in.
This is useful, and actually if we type the characters
l and s in there for list and hit Enter,
we'll see a list of all files
and sub folders in this directory.
But I actually want to show you where
Python lives on this machine.
So we're going to change
the directory with the command cd.
On the Coursera system,
we're using a specific installation
for Python called Anaconda.
Don't worry too much about that.
Let's just change to the site-packages directory.
This is the real heart of the Python library ecosystem.
So I'll go cd/opt/Conda/lib/ Python3.7/site-packages.
When we do this,
then do a directory listing,
we see a whole bunch of things.
First, there's a lot of
interesting files and directories in here.
These are the third party packages for Python,
which are installed on the system.
We're going to be dealing with a lot of new packages,
but I want you to feel empowered to explore a bit.
These packages are just Python files,
or sometimes other languages as well,
which have been configured to work with
the current Python environment.
Let's take a look at one that I'm
familiar with called pillow.
Pillow is an imaging library for Python.
We can see that it's installed here
because there's a pillow egg file.
We can actually look at the source code of
the Pillow library by going into the pill directory.
So let's cd PIL.
You'll see that when we do an ls,
most of these files are just dot py files.
Python code itself.
We can even take a look at the Python source code behind
this library using the more command here.
Let's look at the main python file in
this library called image.py.
So more image.py.
We can see that there's a bunch of comments at the top
reaching all the way back to 1995.
We see a few import statements,
then some top-level variables like a logger.
We won't talk much about loggers,
but they're handy when debugging code.
Then we see that there are a few classes
which are created,
then a math expression,
then a try and except block, and so forth.
You can feel free to explore
this library more by hitting the space bar,
or you can exit with more command by hitting q.
So that's a very brief overview of
where Python libraries exist on your system.
Now, that's not exactly a user friendly way to
interact with the library by reading the source code,
but it's a great way to learn how libraries work,
and how programmers create complex Python solution.
But let's go back into the Jupyter notebook and
explore how to actually use this library.