diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/installing-python-linux.md b/installing-python-linux.md index f9650bf..cf0b03e 100644 --- a/installing-python-linux.md +++ b/installing-python-linux.md @@ -10,7 +10,7 @@ In this course, you'll be writing lots of Python code, so it's important to get Throughout this document, we will: -1. Install Python 3.9.2 +1. Install Python 3.10.3 2. Create a virtual environment using this version of Python. 3. Inside this environment, install useful packages. @@ -18,9 +18,9 @@ Let's get started! ## Prerequisite -We assume that you have a basic familiarity with the command line. We understand that not everyone will feel comfortable with the command line, because it is covered starting in CS107. However, I highly recommend using Nick Troccoli's amazing [CS107 resources](https://web.stanford.edu/class/archive/cs/cs107/cs107.1194/resources/) for this quarter if you feel less experienced, particular the section titled "Common Unix Commands." +We assume that you have a basic familiarity with the command line. We understand that not everyone will feel comfortable with the command line, because it is covered starting in CS107. However, I highly recommend using Nick Troccoli's amazing [CS107 resources](https://web.stanford.edu/class/archive/cs/cs107/cs107.1214/resources/) for this quarter if you feel less experienced, particular the section titled "Common Unix Commands." -## Install Python 3.9.2 +## Install Python 3.10.3 On different Linux systems, there are a couple of different ways to install and manage packages. We'll cover `apt-get` here, as well as how you can install from source. @@ -31,11 +31,11 @@ On different Linux systems, there are a couple of different ways to install and ``` $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update -$ sudo apt-get install python3.9 -$ sudo apt-get install python3.9-venv +$ sudo apt-get install python3.10 +$ sudo apt-get install python3.10-venv ``` -On Debian, we'll just have to `sudo apt-get install python3` and hope for the best. Also note that this might install a different version of Python 3.9, but we won't worry about that here. +On Debian, we'll just have to `sudo apt-get install python3` and hope for the best. Also note that this might install a different version of Python 3.10, but we won't worry about that here. ### Installing with `yum` (RedHat, CentOS) @@ -43,13 +43,13 @@ Other Linux distributions use a different package manager, `yum`. We don't have ### Other Linux package managers -The world of Linux distributions is unfathomably large. If you can pull off a Python 3.9 install on your distribution of choice, more power to you. However, we recommend building from source. +The world of Linux distributions is unfathomably large. If you can pull off a Python 3.10 install on your distribution of choice, more power to you. However, we recommend building from source. ### Installing from source Installing Python from source follows the same pattern as most other source installations. -First, download the source tarball (either [gzipped](https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz) or [XZ compressed](https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tar.xz)). Unzip the files and `cd` into the unzipped directory. +First, download the source tarball (either [gzipped](https://www.python.org/ftp/python/3.10.3/Python-3.10.3.tgz) or [XZ compressed](https://www.python.org/ftp/python/3.10.3/Python-3.10.3.tar.xz)). Unzip the files and `cd` into the unzipped directory. To build Python, just execute the usual commands: diff --git a/installing-python-macos.md b/installing-python-macos.md index 34495b7..915a64c 100644 --- a/installing-python-macos.md +++ b/installing-python-macos.md @@ -10,30 +10,26 @@ In this course, you'll be writing lots of Python code, so it's important to get Throughout this document, we will: -1. Install Python 3.9.2 +1. Install Python 3.10.3 2. Create a virtual environment using this version of Python. 3. Inside this environment, install useful packages. 4. (Optional) Modify the shell startup script to always activate our environment. Let's get started! -## Install Python 3.9.2 +## Install Python 3.10.3 *Note: If you use `brew` or another package manager for Python installations, see the note at the bottom of this section instead.* -Navigate to the [Python 3.9.2 download page](https://www.python.org/downloads/release/python-392/) in a web browser. +Navigate to the [Python 3.10.3 download page](https://www.python.org/downloads/) in a web browser. -Scroll to the bottom of the page to the section labelled "Files." +Navigate to the top of the page where it says "Looking for Python with a different OS? Python for..." and select your operating system/computer mode. -Install the Python distribution that corresponds to your version of macOS. If you are running OS X 10.9 (Mavericks) or later on an Intel processor, download the ["macOS 64-bit Intel installer."](https://www.python.org/ftp/python/3.9.2/python-3.9.2-macosx10.9.pkg). If you are running OS X 10.9 (Mavericks) or later on Apple Silicon, download the experimental ["macOS 64-bit universal2 installer"](https://www.python.org/ftp/python/3.9.2/python-3.9.2-macos11.pkg). +After downloading, double-click the downloaded file, and follow the on-screen instructions to install Python 3.10.3 -If you are running OS X 10.6 (Snow Leopard), OS X 10.7 (Lion), or OS X 10.8 (Mountain Lion), you will need to download an older version of Python; Python 3.7.6 can be downloaded at [this link](https://www.python.org/downloads/release/python-376/) by clicking on the ["macOS 64-bit/32-bit installer"](https://www.python.org/ftp/python/3.7.6/python-3.7.6-macosx10.6.pkg). If you need, you can determine which macOS your computer is running with [these instructions from Apple](https://support.apple.com/en-us/HT201260). +Let's double check that Python 3.10.3 was installed correctly. -After downloading, double-click the downloaded file, and follow the on-screen instructions to install Python 3.9.2. - -Let's double check that Python 3.9.2 was installed correctly. - -For the remainder of this setup document, we assume that you have a basic familiarity with the command line. We understand that not everyone will feel comfortable with the command line, because it is usually covered starting in CS107. However, I highly recommend using Nick Troccoli's amazing [CS107 resources](https://web.stanford.edu/class/archive/cs/cs107/cs107.1194/resources/) for this quarter if you feel less experienced, particular the section titled "Common Unix Commands." +For the remainder of this setup document, we assume that you have a basic familiarity with the command line. We understand that not everyone will feel comfortable with the command line, because it is usually covered starting in CS107. However, I highly recommend using Nick Troccoli's amazing [CS107 resources](https://web.stanford.edu/class/archive/cs/cs107/cs107.1214/resources/) for this quarter if you feel less experienced, particular the section titled "Common Unix Commands." The main takeaway is the following: If you something of the following form in this guide (you'll see this quite a few times!): @@ -48,25 +44,23 @@ Two quick notes: 1. The text before the `$` can vary. It is not necessarily your username. In this case, we are assuming that the username is `coopermj` and that is the text which is shown before the `$` at your command prompt. (On the terminal below, for example, the text before the prompt includes more than just the username, including the current directory). 2. Below is a quick example of how you may go about running the commands immediately following this list. This is designed to clear up any ambiguity related to running commands at the command line. -![](term_example.png) Open up a command line prompt (likely using Terminal), and run the following commands: ``` coopermj$ which python3 -/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 +/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 coopermj$ python3 --version -Python 3.9.2 +Python 3.10.3 ``` -If you see the output shown above, then Python 3.9.2 was installed correctly on your machine! +If you see the output shown above, then Python 3.10.3 was installed correctly on your machine! Let's celebrate by writing some code! Run the following from a command prompt. You should see the following output, which leaves you at an interactive prompt, at which you can write Python code. ``` coopermj$ python3 -Python 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) -[Clang 6.0 (clang-600.0.57)] on darwin +Python 3.10.3 (v3.10.3:a342a49189, Mar 16 2022, 09:34:18) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> print("Hello world!") Hello world! @@ -80,17 +74,17 @@ Try writing some Python (perhaps `print("Hello world!")`) in the interactive int [Homebrew](https://brew.sh/) is "the missing package manager for macOS." It's a great way to install, upgrade, and manage many different types of packages on macOS, including Python. If you are not using `brew`, there is no requirement that you start for CS41. However, if you are already using `brew`, you might as well install Python through brew. -Run `brew install python3`. This will fetch the latest version of Python (which might not be Python 3.9.2, but that's all we can do). +Run `brew install python3`. This will fetch the latest version of Python (which might not be Python 3.10.3, but that's all we can do). -Then, continue the process above, after the installation of Python 3.9.2. +Then, continue the process above, after the installation of Python 3.10.3. ### Troubleshooting #### `which python3` shows no output The `which` command searches your computer for a program matching a name. If `which python3` shows no output, it means that your computer can't find any appropriate `python3`. Pause and reach out to a member of the course staff to help you debug. Include as much detail as you can about the problem. -#### `python3 --version` does not show `Python 3.9.2` -In this case, the version of Python 3 your computer wants to run is not the Python 3.9.2 that we just downloaded. Pause and reach out to a member of the course staff to help you debug. Include as much detail as you can about the problem. +#### `python3 --version` does not show `Python 3.10.3` +In this case, the version of Python 3 your computer wants to run is not the Python 3.10.3 that we just downloaded. Pause and reach out to a member of the course staff to help you debug. Include as much detail as you can about the problem. ## Create a virtual environment @@ -100,7 +94,7 @@ Specifically, we will create a folder named `cs41-env` in your computer's home f ``` coopermj$ python3 --version -Python 3.9.2 +Python 3.10.3 coopermj$ python3 -m venv ~/cs41-env ``` @@ -154,22 +148,22 @@ Moreover, observe that: ``` (cs41-env) coopermj$ python3 --version -Python 3.9.2 +Python 3.10.3 (cs41-env) coopermj$ python --version -Python 3.9.2 +Python 3.10.3 (cs41-env) coopermj$ pip3 --version -pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9) +pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip (python 3.10) (cs41-env) coopermj$ pip --version -pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9) +pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip (python 3.10) ``` -The big takeaway is that, inside our active virtual environment, the commands `python` and `pip` now refer to Python 3.9.2 and it's associated package manager. +The big takeaway is that, inside our active virtual environment, the commands `python` and `pip` now refer to Python 3.10.3 and it's associated package manager. For example, when the virtual environment is active, we can enter an interactive Python 3 prompt simply by running: ``` coopermj$ python -Python 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) +Python 3.10.3 (v3.10.3:1a79785e3e, Feb 19 2021, 09:06:10) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> @@ -189,7 +183,7 @@ Now, we'll update `pip`, Python's builtin package manager, just to make sure it' ``` (cs41-env) coopermj$ pip install --upgrade pip -Requirement already up-to-date: pip in ./cs41-env/lib/python3.8/site-packages (21.0.1) +Requirement already up-to-date: pip in ./cs41-env/lib/python3.10/site-packages (21.0.1) ``` After, we'll install the suite of Jupyter tools and some additional useful packages. @@ -218,7 +212,7 @@ Importantly, you should now have access to `ipython`, an interactive Python inte ``` (cs41-env)$ ipython -Python 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) +Python 3.10.3 (v3.10.3:1a79785e3e, Feb 19 2021, 09:06:10) Type 'copyright', 'credits' or 'license' for more information IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help. @@ -245,7 +239,7 @@ And that's it! You are all done setting up your Python development environment f ## Summary -First, we installed Python 3.9.2 from the Python website and checked that everything was installed correctly. Next, we used `python3` to create a virtual environment named `cs41-env`, and we learned how to activate and deactivate this virtual environment. Lastly, we activated the environment and installed lots of useful packages. +First, we installed Python 3.10.3 from the Python website and checked that everything was installed correctly. Next, we used `python3` to create a virtual environment named `cs41-env`, and we learned how to activate and deactivate this virtual environment. Lastly, we activated the environment and installed lots of useful packages. **Reminder: Each time you create a new terminal session, you will need to run `source ~/cs41-env/bin/activate`.** diff --git a/installing-python-windows.md b/installing-python-windows.md index 2e4fcf2..d693b2c 100644 --- a/installing-python-windows.md +++ b/installing-python-windows.md @@ -30,15 +30,15 @@ Once you're in the `bash` shell, you can follow the [Linux](https://github.com/s ``` $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update -$ sudo apt-get install python3.9 -$ sudo apt-get install python3.9-venv +$ sudo apt-get install python3.10 +$ sudo apt-get install python3.10-venv ``` You can check which version of Python you've installed by running: ``` $ python3 --version -Python 3.9.2 +Python 3.10.3 ``` In broad strokes, you will need to run the following commands to set up a virtual environment. The Linux and macOS handouts contain more detailed information. @@ -60,7 +60,7 @@ Working with Windows is complicated enough, so we're going to omit the instructi Recall that we discourage this option as it is very complex and hard for us to debug. Only use this option if the above fails and you don't want to use a VM (Strategy 3) for some reason. -You will need Windows 8.1 or newer to use Python 3.9.2 on Windows. +You will need Windows 8.1 or newer to use Python 3.10.3 on Windows. When in doubt, the source of truth for Windows commands is [included in the Python documentation](https://docs.python.org/3/using/windows.html), and you can find more details on using virtual environments [here](https://docs.python.org/3/library/venv.html#module-venv). @@ -70,13 +70,13 @@ The rough outline is: 2. Create a virtual environment. 3. Use `pip` to install useful packages. -First, download the web-based installer from the [Python 3.9.2 releases page](https://www.python.org/downloads/release/python-392/), either for [x86-64](https://www.python.org/ftp/python/3.9.2/python-3.9.2-amd64-webinstall.exe) or [x86](https://www.python.org/ftp/python/3.9.2/python-3.9.2-webinstall.exe). The web-based installer is a small download which will connect to the internet to download any additional required components, so make sure that you are connected to the internet for the remainder of these installation instructions. +First, download the web-based installer from the [Python 3.10.3 releases page](https://www.python.org/downloads/release/python-392/), either for [x86-64](https://www.python.org/ftp/python/3.10.3/python-3.10.3-amd64-webinstall.exe) or [x86](https://www.python.org/ftp/python/3.10.3/python-3.10.3-webinstall.exe). The web-based installer is a small download which will connect to the internet to download any additional required components, so make sure that you are connected to the internet for the remainder of these installation instructions. -Start the installer. You will see two options: "Install launcher for all users (recommended)" and "Add Python 3.9 to PATH". Make sure both are selected, and then click "Install Now." +Start the installer. You will see two options: "Install launcher for all users (recommended)" and "Add Python 3.10 to PATH". Make sure both are selected, and then click "Install Now." *Note: Technically, you should also [remove the MAX_PATH limitation](https://docs.python.org/3/using/windows.html#removing-the-max-path-limitation), but we'll skip that for now.* -Follow the on-screen instructions to finish installing Python. When you are given the option of unchecking any 'optional' components, do not uncheck any. In particular, if there is an option called "Add python.exe to search path" on the "Customize Python 3.9" screen, make sure that box is checked! You should also see that `pip` is being installed by default. +Follow the on-screen instructions to finish installing Python. When you are given the option of unchecking any 'optional' components, do not uncheck any. In particular, if there is an option called "Add python.exe to search path" on the "Customize Python 3.10" screen, make sure that box is checked! You should also see that `pip` is being installed by default. Let's check to see that everything was installed correctly. @@ -89,13 +89,13 @@ Open up PowerShell or `cmd.exe` and run the following from a command prompt: You should see something like the following: ``` -Python 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) +Python 3.10.3 (v3.10.3:1a79785e3e, Feb 19 2021, 09:06:10) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ``` -Ensure that the Python version above looks like 3.9.2. +Ensure that the Python version above looks like 3.10.3. If that doesn't work, try running: @@ -103,7 +103,7 @@ If that doesn't work, try running: > python ``` -If this drops you into a Python 3.9.2 interactive interpreter, great! In this case, everywhere you see `python3` below, replace it with the command `python`. +If this drops you into a Python 3.10.3 interactive interpreter, great! In this case, everywhere you see `python3` below, replace it with the command `python`. If this didn't work, try running: @@ -116,16 +116,16 @@ If this worked, then everywhere you see `python3` below, replace it with the com Try writing some Python in the interactive interpreter! When you're done, you can exit the interactive interpreter with `CTRL+C` or by entering `quit()` at the Python command prompt. ### Checking `pip` -First, let's check that we have `pip` installed. For CS41, we'll be using a package manager called `pip` to install and manage Python software packages. By default, Python 3.9.2 ships with a version of `pip` prebuilt. `pip` interacts very well with PyPI (the Python Package Index), so we'll be using `pip` extensively this quarter. +First, let's check that we have `pip` installed. For CS41, we'll be using a package manager called `pip` to install and manage Python software packages. By default, Python 3.10.3 ships with a version of `pip` prebuilt. `pip` interacts very well with PyPI (the Python Package Index), so we'll be using `pip` extensively this quarter. At a command prompt, run the following code. You should see something like the following output: ``` > python3 -m pip --version -pip 21.0.1 from /pip 21.0.1 from C:\Users\Parth\AppData\Local\Programs\Python\Python38\lib\site-packages (python 3.9) +pip 21.0.1 from /pip 21.0.1 from C:\Users\Parth\AppData\Local\Programs\Python\Python38\lib\site-packages (python 3.10) ``` -Problems might arise if you had a different version of Python 3 already installed, but if you added Python 3.9 to your PATH, this should work. +Problems might arise if you had a different version of Python 3 already installed, but if you added Python 3.10 to your PATH, this should work. ### Create a Virtual Environment diff --git a/term_example.png b/term_example.png index 75f8566..6fc6b9b 100644 Binary files a/term_example.png and b/term_example.png differ