\documentclass[../book.tex]{subfiles}
\graphicspath{{\subfix{.}}}
\begin{document}
\chapter{Getting Python3 and the Spyder IDE working}

The process for installing Python depends on the operating system you are using.  So, we have split this into two parts: Windows and OSX/Linux. 

No matter which operating system you have, you are going to need to add libraries to it. \textbf{We cannot stress how important it is that you do this correctly.  Please read the chapter on using pip! If you don't know what you are doing READ THAT SECTION FIRST.}

\section*{Windows}
Getting Python up and running is straightforward on a Windows machine. If you don't know if you are using Windows, there are a few simple ways to tell.  The simplest is to look in the bottom left of your screen.  If there is a Windows symbol, then you are using Windows. 

IMAGE of windows icon

If you are using Windows, then you can follow these step to install. 

\subsection{Step 1: Ensure you don't already have Python installed}

The first thing to do is make sure you don't already have Python3 installed, because having multiple installations is a headache you really don't want. To do this, open up a command prompt, by entering `cmd' in the text bar in the bottom left of your screen and pressing enter. This will open a black text-based window.

In this window, type `where Python3' and press enter. You will have one of two responses:
\begin{itemize}
    \item \texttt{INFO: Could not find files for the given pattern(s)} This means that Python is \textbf{not} installed, and you should continue to Step 2.
    
    \item a file path to the place Python3 is installed. If this is the case, you have Python3 installed, and you can continue to Step 3. 
\end{itemize}

\subsection{Step 2: Install Python3}
Open up \href{https://www.python.org/downloads/}{https://www.python.org/downloads/}  Once there, you should see a large button to download Python3.  Click that, and once downloaded, open the file and follow the instructions for the installer.  The most important thing to do is to note the location of where you installed Python3.  However, if you don't do this, then we can find it later, don't worry. 

Once Python3 is installed, move on to Step 3. 

\subsection{Validate Python3 install}

Open up a cmd prompt and type in Python3.  This should start a Python session, with a prompt similar to what you saw in Chapter 00. You can try some Python commands, like \texttt{print("hi")} and ensure they work.\footnote{NOTE: you may not yet be able to use numpy, so don't try things like making numpy arrays!} If this works, move on to Step 4.  If not, then you need help. 

\subsection{Step 4: Install the Spyder IDE}
Open up \href{https://www.spyder-ide.org/}{https://www.spyder-ide.org/} and navigate to the `Downloads'.  There should be a large button, and you can click this and download the installer.  Once downloaded, you can run the installer.  The default values are fine, but change things as you like. 

Once installed, move on to Step 5

\subsection{Step 5: Getting Spyder to use Python3}
Open up the Spyder application.  Once open, go to File > Preferences. Once there select "Python interpreter" from the left panel, and make sure that radio button for  "use the following Python interpreter" is selected and then make sure that you add the path to the Python3 installation you have on your machine.  If you do not remember where this is, you can open a cmd prompt and enter \texttt{where Python3}, which will give you the result. 

Save these changes and move on to step 6.

\subsection{Step 6: Validate}

Now, you can try to use Spyder to perform Python operations.  For instance, you can open up a new file, type \texttt{print("Hi!")}, then run the file and see if it works.  If so, you are good to go!  If not, you need help. 

\section{MacOS and Linux}
Getting things working on the MacOS is a bit harder.  This is, in part, because MacOS comes with Python installed, BUT not in a way that you can use. In fact, \textit{you should be very careful to avoid altering the Python natively inststalled on your Mac.}

This is somewhat complicated by the fact that newer (i.e., Catalina and later) operating systems do \textit{not} have Python pre-installed.  So, we are sorry this is sort of a mess, but that is how it is. 

So, the first thing to do (if you are on MacOS) is to figure out if you already have Python3 installed, and if it is native. If you are on Linux, you do not have this problem, and can skip to step 1.

\subsection{Step 0: Figuring out if you have Python3 installed}
Open up a console window, and type in 'which Python3'.  You will get one of two responses. 
\begin{itemize}
    \item not .  Congratulations!  This is the simplest case.  You do not yet have Python3 installed, and can proceed to step 1.

    \item A list of multiple places that Python exists.  Now, there are three more options
    \begin{itemize}
        
        
        \item there is a single entry, which looks like: '/usr/bin/python3'.  This is the default installation, and you have no others ones.  You need to install Python3, and you can skip on to Step 1.

        \item You see a single line, and it is \textit{not} something like: `/usr/bin/python3'  You already have Python3 installed and it is \textit{not} the default application.  You can skip to step 4. 

        \item you see many different lines, one of which is '/usr/bin/python3'.  This means you have Python installed as a default application and also at least one installation that is not your default application. This can be a challenge...
    \end{itemize}
\end{itemize}

\subsection{Validate Python3 install}

Open up a console window and type in Python3.  This should start a Python session, with a prompt similar to what you saw in Chapter 00. You can try some Python commands, like \texttt{print("hi")} and ensure they work.\footnote{NOTE: you may not yet be able to use numpy, so don't try things like making numpy arrays!} If this works, move on to Step 4.  If not, then you need help. 

\subsection{Step 4: Install the Spyder IDE}
Open up \href{https://www.spyder-ide.org/}{https://www.spyder-ide.org/} and navigate to the `Downloads'.  There should be a large button, and you can click this and download the installer.  Once downloaded, you can run the installer.  The default values are fine, but change things as you like. 

Once installed, move on to Step 5

\subsection{Step 5: Getting Spyder to use Python3}
Open up the Spyder application.  Once open, go to File > Preferences. Once there select "Python interpreter" from the left panel, and make sure that radio button for  "use the following Python interpreter" is selected and then make sure that you add the path to the Python3 installation you have on your machine.  If you do not remember where this is, you can open a console window and enter \texttt{which Python3}, which will give you the result. If you have followed along this guide, hopefully you know which path to use. 

Save these changes and move on to step 6.

\subsection{Step 6: Validate}

Now, you can try to use Spyder to perform Python operations.  For instance, you can open up a new file, type \texttt{print("Hi!")}, then run the file and see if it works.  If so, you are good to go!  If not, you need help. 

\section{Using pip}

\end{document}