|
| 1 | +# Installing Python 3 |
| 2 | + |
| 3 | +<img src="https://training.talkpython.fm/static/img/cms/nopy-final.jpg" style="border-radius: 10px; display: block;" class="img img-responsive" /> |
| 4 | + |
| 5 | +Welcome soon to be Python user! Python is one of the easiest programming languages to learn and grow with. But there are a few bumps right at the beginning. **One of these bumps is to make sure you have Python installed** and that it's a sufficiently new version (generally 3.6+ is solid these days). |
| 6 | + |
| 7 | +Because how you install and verify Python varies by operating system, we've put together this short guide. It's goal is to give you exposure to the various ways on your operating system to **install and maintain Python in a concise and no-nonsense manner**. So with out further ado, let's get you setup! |
| 8 | + |
| 9 | +## Step 1. Go To Your Operating System |
| 10 | + |
| 11 | +As mentioned above, how you verify Python and subsequently install it is specific to the operating system. So jump to [Windows](#windows), [macOS](#macos), or [Linux](#linux) to continue. |
| 12 | + |
| 13 | +<a id="windows"></a> |
| 14 | +_________________________ |
| 15 | + |
| 16 | +## Windows |
| 17 | + |
| 18 | +### Step 2. Do you have Python? Let's check |
| 19 | + |
| 20 | +To determine if you have Python installed, open the [**command prompt**](https://www.lifewire.com/how-to-open-command-prompt-2618089) or install (preferred) [**new Windows Terminal**](https://devblogs.microsoft.com/commandline/introducing-windows-terminal/) from the [**Microsoft Store**](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701?activetab=pivot:overviewtab). |
| 21 | + |
| 22 | +Verify you have Python, in the command prompt / terminal, type **python -V** (capital V): |
| 23 | + |
| 24 | +``` |
| 25 | +C:\users\username\> python -V |
| 26 | +``` |
| 27 | + |
| 28 | +The output should be one of the following (*version numbers will vary*). **C:\users\username\> is not typed** - Windows displays this as part of the terminal UI. |
| 29 | + |
| 30 | +#### Success, you have Python |
| 31 | + |
| 32 | +``` |
| 33 | +C:\users\username\> python -V |
| 34 | +Python 3.9.2 |
| 35 | +``` |
| 36 | + |
| 37 | +If you see this and the reported version number is sufficently high (often 3.6 or higher), **you are good to go**. |
| 38 | + |
| 39 | +#### Uh oh, your Python is badly outdated |
| 40 | + |
| 41 | +``` |
| 42 | +C:\users\username\> python -V |
| 43 | +Python 2.7.18 |
| 44 | +``` |
| 45 | + |
| 46 | +If you have `Python 2.*`, then you are using an outdated version of Python. [**Since 2020, Python 2 has gone entirely unsupported**](https://stackoverflow.blog/2020/04/23/the-final-python-2-release-marks-the-end-of-an-era/) and should not be used. **You will need to continue below to install Python 3**. |
| 47 | + |
| 48 | +#### Ooops, you do NOT have Python |
| 49 | + |
| 50 | +``` |
| 51 | +C:\users\username\> python -V |
| 52 | +'python' is not recognized as a command or program. |
| 53 | +``` |
| 54 | + |
| 55 | +Looks like you do not have Python at all. **You will need to continue below to install Python 3**. Note that the error message is slightly different for **Windows Terminal**: *The term python is not recognized as a cmdlet, function, or operable program*. |
| 56 | + |
| 57 | +#### Ooops, you still do NOT have Python |
| 58 | + |
| 59 | +``` |
| 60 | +C:\users\username\> python -V |
| 61 | +Python was not found; run without arguments to install from the Windows Store... |
| 62 | +``` |
| 63 | + |
| 64 | +Looks like you do not have Python at all. **You will need to continue below to install Python 3**. When you see this specific error message, it means that Python is not installed. What is running is a shim program meant to help you install Python 3 from the Windows Store (one option below). You can select this option by simplying typing `python` and following along in the UI. |
| 65 | + |
| 66 | + |
| 67 | +### Step 3. You need Python, install it on Windows |
| 68 | + |
| 69 | +So you need to install a new version of Python on your Windows machine. There are a variety of options for doing so. We'll run you through them, but **if you are uncertain which one to get, just use the official installer**. Keep in mind that no matter how you install Python, **you will likely need to close and reopen your terminal/command prompt for any changes to take effect**. |
| 70 | + |
| 71 | +- **Python Official Installer** << default |
| 72 | +- Windows Store |
| 73 | +- Chocolatey Package Manager for Windows |
| 74 | +- Anaconda Distribution |
| 75 | + |
| 76 | +**Python Official Installer on Windows** |
| 77 | + |
| 78 | +The Python official installer can be found on **[python.org](http://python.org)**. |
| 79 | + |
| 80 | +**Pros**: This is a good option |
| 81 | + |
| 82 | +* It's the primary way the Python Software Foundation delivers Python to users |
| 83 | +* The installer is supported by core developers working at Microsoft |
| 84 | + |
| 85 | +**Cons**: There is no autoupdate option. |
| 86 | + |
| 87 | +* You will not be notified of possible updates |
| 88 | +* There is no mechanism to have a new version automatically replace the installed version |
| 89 | + |
| 90 | +**Install steps**: |
| 91 | + |
| 92 | +1. Visit the **[downloads page for Windows](https://www.python.org/downloads/windows/)** |
| 93 | +2. Find the section entitled **Stable Releases** |
| 94 | +3. Download the MSI installer under the **Download Windows installer (64-bit)** link |
| 95 | +4. Run the installer - **be sure to check the "add python to my path" option** |
| 96 | +5. Close all terminal and command prompt windows |
| 97 | +6. Run `python -V` in a new terminal window to verify you have Python now working |
| 98 | + |
| 99 | +**Windows Store version of Python** |
| 100 | + |
| 101 | +The Windows Store version of Python is a good option. It's the easiest way to get Python on Windows without administrator permissions. But there are some drawbacks too. |
| 102 | + |
| 103 | +**Pros**: |
| 104 | + |
| 105 | +* Easiest way to get Python on Windows without administrator permissions |
| 106 | +* Will keep Python up-to-date automatically within a release version (3.9 updates but not 3.9->3.10) |
| 107 | +* Maintained by the core developers who work at Microsoft |
| 108 | + |
| 109 | +**Cons**: |
| 110 | + |
| 111 | +* Does have some minor permission restrictions that apply to all Windows Store apps which can affect your development options |
| 112 | + |
| 113 | +**Install steps**: |
| 114 | + |
| 115 | +1. Open the Microsoft Store on Windows |
| 116 | +2. Search for Python |
| 117 | +3. Find the latest version of Python from Microsoft (currently lists 3.7, 3.8, and [3.9](https://www.microsoft.com/en-us/p/python-39/9p7qfqmjrfp7?activetab=pivot:overviewtab)) |
| 118 | +4. Install from the Microsoft Store |
| 119 | +5. Close all terminal and command prompt windows |
| 120 | +6. Run `python -V` in a new terminal window to verify you have Python now working |
| 121 | + |
| 122 | + |
| 123 | +### Step 4. Ensure Python 3 is in the path correctly. |
| 124 | + |
| 125 | +<a id="macos"></a> |
| 126 | +_________________________ |
| 127 | + |
| 128 | +## macOS |
| 129 | + |
| 130 | +### Step 2. Do you have Python? Let's check |
| 131 | + |
| 132 | +### Step 3. You need Python, install it on macOS |
| 133 | + |
| 134 | +- Homebrew |
| 135 | +- Installer |
| 136 | +- Anaconda |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | +## Linux |
| 141 | + |
| 142 | +### Step 2. Do you have Python? Let's check |
| 143 | + |
| 144 | +### Step 3. You need Python, install it Linux |
| 145 | + |
| 146 | +- Package manager |
| 147 | +- Anaconda |
| 148 | +- [From source](Building python from source on Ubuntu 20.04 LTS Focal Fossa) |
0 commit comments