Step 1: Download
1. Go to [python.org/downloads/windows](https://www.python.org/downloads/windows/)2. Pick Python 3.10.X (replace X with the highest number available) 3. Verify there's a `Windows embeddable package` or a `Windows Installer`4. Select 64bit or 32bit to match your system.Need help selecting 64/32 bit?- Do a Cortana search for `System Information`, open it- look for `System Type`- mine says `x64-based PC` which means mine is 64-bit and I should download the `Windows x86-64 executable installer`
Step 2: Open Python Installer
1. Navigate to the Python installer you downloaded in step 1.2. Open it3. Do not Tick/Select `Add Python 3.10 to PATH`. We'll call python directly in later steps.4. Select `Customize Installation` (this is important)5. Tick/Select `pip` (others, leave as default)6. Hit next7. Tick/Select:- `Install for all users`- `Add Python to environment variables`- `Create shortcuts for installed applications`- `Precomplie standard library`8. Customize Install Location and use:```C:\Python310```Personally, I like using this location for all my installs of python so I can know exactly what command to type to grab the version I might need. (Such as `C:\Python310\python.exe` for Python 3.10 or `C:\Python38\python.exe` for Python 3.8)9. Hit `Install`
Step 3: Verify Python Installed via PowerShell
1. Search/Open **Windows PowerShell**2. Type:```C:\Python310\python.exe -V``` 3. Hit enter. You should see the following:```Python 3.10.2 ```4. If typing the above fails, try:- `python -V` (this means you added it to your `PATH` which is not recommended)- Restart Computer- Uninstall python and redo step 2 above.5. Verify pip by entering:```C:\Python310\python.exe -m pip freeze```If you see `The term 'pip' is not recognized as the name...` then you do the installation incorrectly and might need to revert to a previous step. Otherwise, you're good.
Step 4: Update PowerShell Settings
You should only have to do this 1 time, if done correctly.1. Search Windows Powershell (a search is important)2. Right click, select _Run as Administrator_; confirm security pop-up if needed3. Enter: ```Set-ExecutionPolicy Unrestricted```
Step 5: Create Dev Folder
1. Open `Windows PowerShell` (not needed to run as Admin now)2. Type:```cd ~/mkdir Dev```I use the `Dev` folder to store all of my Python projects as well as other code-related projects.
Step 6: Update Pip
In `PowerShell` write the following command:```C:\Python310\python.exe -m pip install pip --upgrade```Let's break this down:- `C:\Python310\python.ex -m` is the command to run built-in modules for python- `pip` is a built-in Python module. It's called the Python Package Installer which allows you to install third-party Python packages from pypi.org- `pip install pip`; yes pip is attempting to install itself- `--upgrade` this is what you'll do when you need to update any of your python packages automatically
Step 7: Create a Virtual Environment
Remember how in step 1 we installed the latest version of Python 3.10? What if we wanted our system to use Python 3.6? Or Python 3.8? Technically speaking, this is *definitely* possible but it poses a new problem:**If you write a program using a specific version of Python, it may or may not work using another version of Python.**Hopefully you see the logic in the fact that if you use Python 2.7 to write a program it *might not* run on Python 3.10 simply because they are different versions.How do we solve version issues?By using `Virtual Environments`As a beginner, this step might *feel pointless* but I promise as your skills grow you will certainly come to appreciate this step.Here's what you need to do:1. Create a Project directory```cd C:\Devmkdir my_test_project```2. Initialize the virtual environment```C:\Python310\python.exe -m venv myvenv```Do you see how we used `C:\Python310\python.exe -m` again? Yup, `venv` is a built-in package to Python.`myvenv` is the name of the virtual environment (in this case).3. Activate your virtual environment```.\myvenv\Scripts\activate```4. Update pip```(myvenv) python -m pip install pip --upgrade```Notice how I no longer have to use `C:\Python310\python.exe`?5. Deactivate and reactivateTo deactivate, just type:```(myvenv) deactivate```To reactivate type:```.\myvenv\Scripts\activate```You will *reactivate* your virtual environment(s) every time you need to run code related to this project.
Step 8: Install any Python Package
Let's continue from our virtual environment in the previous step:Open up PowerShell and run:```cd Devcd my_test_project.\myvenv\Scripts\activate(myvenv) python -m pip install Django(myvenv) python -m pip install requests```This will install the latest version of Django and Python requests.