Skip to content

Proofread, reorganized, and added to all the "Python on Windows" guides #794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
efa1ef3
Rewrote and added more info to python on ms store article
discretegames Nov 5, 2022
952c4a5
added right aligned drake image and a few tweaks to ms store guide
discretegames Nov 5, 2022
13779f3
final tweaks to ms store article
discretegames Nov 6, 2022
3668202
Redid windows guide titles/slugs/descriptions to be consistent with p…
discretegames Nov 6, 2022
19caa0a
Rewrote safe method for adding Python to path, in own article
discretegames Nov 6, 2022
40ad001
finished detailed, screenshot full, putting python on path guide
discretegames Nov 7, 2022
a7c59dd
Proofread, tweaked, added links to common windows issues guide. (Also…
discretegames Nov 7, 2022
4d734b0
tweaks and link fixes to windows guides, still in reorg process
discretegames Nov 7, 2022
f1961a0
reorg of windows guides, moved py launcher into installing and using,…
discretegames Nov 8, 2022
4bb5c57
added toc to windows guides
discretegames Nov 8, 2022
54a596e
Finished recommended Python Windows install instructions
discretegames Nov 8, 2022
3dc24ec
completed more install info section of Windows guide
discretegames Nov 8, 2022
c2fdf87
re-added venv section to windows guide
discretegames Nov 8, 2022
790d076
finished py launcher section, finishing Windows guide reorg
discretegames Nov 8, 2022
ee5e1ba
Added WSL2 section to windows guide; other tweaks
discretegames Nov 8, 2022
c7f37e9
Proofread windows guides and added image links everywhere
discretegames Nov 8, 2022
529cc5a
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 9, 2022
6d2db8c
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 9, 2022
c6147f9
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 9, 2022
b3406ec
emphasized NOT
discretegames Nov 9, 2022
0aca0e2
Merge branch 'add-windows-guide' of https://github.com/discretegames/…
discretegames Nov 9, 2022
885eacb
added shtlrs Windows guide suggestions
discretegames Nov 9, 2022
be31bfd
Note about admin needed, and added subheading to Path guide.
discretegames Nov 9, 2022
b8bc86c
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
26f36b2
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
e3975c9
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
0bb9447
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
f612d4c
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
236963d
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
9b21ec8
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
db505b4
Update pydis_site/apps/content/resources/guides/python-guides/windows…
discretegames Nov 13, 2022
d065f2e
Added some of wookies Windows guide review suggestions
discretegames Nov 13, 2022
3dc5756
Merge branch 'add-windows-guide' of https://github.com/discretegames/…
discretegames Nov 13, 2022
c3bb0b5
NOT back to Not and wrapped things to 120chars
discretegames Nov 13, 2022
d59465b
removed import workaround and mentioned 32-bit download in windows gu…
discretegames Nov 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finished py launcher section, finishing Windows guide reorg
  • Loading branch information
discretegames committed Nov 8, 2022
commit 790d076ac2416062466092763b07b22540dee937
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ toc: 3
---

Our recommended way of installing Python on a Windows operating system is using the full installer from the official
[python.org Downloads page](https://www.python.org/downloads/) (the main yellow button) using the default options, except
making sure to check the "Add python.exe to PATH" checkbox. Getting Python from the [Microsoft
[python.org Downloads page](https://www.python.org/downloads/) (the main yellow button) using the default options,
except making sure to check the "Add python.exe to PATH" checkbox. Getting Python from the [Microsoft
Store](https://apps.microsoft.com/store/search/python) is _not_ recommended as [it can cause various
issues](../microsoft-store).

Expand All @@ -27,10 +27,10 @@ Follow the steps below to install the latest version of Python on Windows.
(The instructions were written with Windows 10 and Python 3.11.0 in mind, but should be nearly or fully identical with
Windows 11 or other modern versions of Python.)

> If you want a fresh start, you may want to first uninstall any other versions of Python on your PC, including those from
> the Microsoft Store, if you have any. This can be done in the ["Apps & features" Windows
> settings](/static/images/content/python-on-windows/ms_store_uninstall.png) (type "apps and features" into the Start Menu
> to find it). Though it's fine to have multiple versions of Python installed at once. It can be useful for testing
> If you want a fresh start, you may want to first uninstall any other versions of Python on your PC, including those
> from the Microsoft Store, if you have any. This can be done in the ["Apps & features" Windows
> settings](/static/images/content/python-on-windows/ms_store_uninstall.png) (type "apps and features" into the Start
> Menu to find it). Though it's fine to have multiple versions of Python installed at once. It can be useful for testing
> version compatibility or for working on projects made in a certain version. Only uninstall things if you want to.

1. Go to [python.org/downloads](https://www.python.org/downloads) and click the big yellow "Download Python 3.x.x"
Expand Down Expand Up @@ -70,16 +70,16 @@ and run some code like `print("Hello, World!")`.

[![Testing Python console](/static/images/content/python-on-windows/recommended_install_7.png)](/static/images/content/python-on-windows/recommended_install_7.png)

Or try the more usual way of running Python by typing `py` or `python` in a new terminal window to open up the Python
Or try the more usual way of running Python by typing `python` in a new terminal window to open up the Python
[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop), or use `python somefile.py` to run some
Python file (if `py` runs the wrong version of Python, [see below](#the-py-launcher) for how to change the default). Use
whichever terminal you prefer: Command Prompt, PowerShell, an IDE-integrated terminal, [Windows
Python file. Use whichever terminal you prefer: Command Prompt, PowerShell, an IDE-integrated terminal, [Windows
Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701). It just has to be a freshly opened
terminal or the commands may not be recognized.

[![Testing py and python](/static/images/content/python-on-windows/recommended_install_8.png)](/static/images/content/python-on-windows/recommended_install_8.png)

You can double check what versions of Python and [pip](https://pip.pypa.io/en/stable/) were installed by running `python -V` or `pip -V` in a terminal:
You can double check what versions of Python and [pip](https://pip.pypa.io/en/stable/) were installed by running
`python -V` or `pip -V` in a terminal:

[![Checking python and pip versions](/static/images/content/python-on-windows/testing_path_worked_1.png)](/static/images/content/python-on-windows/testing_path_worked_1.png)

Expand Down Expand Up @@ -152,15 +152,58 @@ search "About your PC" in the Start Menu and open the Settings page. Then look f

## The py Launcher

dg:TODO
By default, when you install Python on Windows from a [python.org installer](https://www.python.org/downloads/windows/),
it comes with the "py launcher". The py launcher is a command line tool you invoke using the `py` command and it helps
you run a specific version of Python when you have multiple versions installed.

The `py` command is not merely shorthand for the `python` command. They are separate programs as can be seen in the
"Apps & features" Windows settings. Though running either of them with no arguments will start the Python
[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop).

The py launcher provides the `py -0` command (or `py --list`) which lists the Python versions you have installed.
`py -0p` does the same but includes the paths to the Python executables.

For example, on my PC I have Python 3.11 and 3.10 installed, and the py launcher shows it:

![py launcher list command](/static/images/content/python-on-windows/py_launcher_1.png)

The versions are ordered from newest to oldest, and the asterisk (`*`) indicates which version running `py` will
currently call by default (3.11 in my case). Exactly which version that is depends on the following requirements, and
may not be the same version you get from running `python` (if you get any).

> If an exact version is not given to `py`, using the latest version can be overridden by the following, (in
> priority order):
>
> - An active virtual environment/
> - A [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) line in the script (if present).
> - With a `-2` or `-3` flag and matching PY_PYTHON2 or PY_PYTHON3 environment variable.
> - A PY_PYTHON environment variable.
> - From `[defaults]` in py.ini in your `%LOCALAPPDATA%` folder.
> - From `[defaults]` in py.ini beside py.exe (usually in `C:\Windows`, use `where.exe py` to locate).

You can give the py launcher an exact version of Python to run (assuming you have it installed) by specifying the major
and minor versions. For example, to invoke Python 3.7, you could run `py -3.7`. You can then pass any arguments on top
of that, for example `py -3.7 myscript.py` to run `myscript.py`, or `py -3.7 -m pip install numpy` to invoke `pip` to
install [NumPy](https://numpy.org/) into Python 3.7.

If you want can always use `py` instead of `python` and not have any Python versions on the Windows Path at all (check
out [this guide](<(../putting-python-on-path)>) to learn about the Windows Path). Though, once in a while third party
software may want to invoke `python`, so keeping it on the Path is handy. We recommend having your "main" Python version
on the Path so you can invoke it with `python`, and then using `py -X.Y` whenever you want a different version, e.g. `py -3.10`.

The official documentation of the `py launcher` can be found
[here](https://docs.python.org/3/using/windows.html#python-launcher-for-windows).

The py launcher is not available on Unix-based platforms such as macOS, but there is [an unofficial version by Brett
Cannon](https://github.com/brettcannon/python-launcher).

## Virtual Environments

Virtual environments ("venvs") are a way of giving each of your Python projects their own space to install dependencies
in, so different projects can have different versions of the same dependencies. For example, suppose you are working on
two websites that both use the Python web-framework [Django](https://www.djangoproject.com/download/). One site is older and
requires Django 3.2, and the other is newer and requires Django 4.1. If you install Django globally, no matter if you
install 3.2 or 4.1, one or the or the other of the projects will have the wrong version. But if you make a virtual
two websites that both use the Python web-framework [Django](https://www.djangoproject.com/download/). One site is older
and requires Django 3.2, and the other is newer and requires Django 4.1. If you install Django globally, no matter if
you install 3.2 or 4.1, one or the or the other of the projects will have the wrong version. But if you make a virtual
environment for each project you can install the required Django version for each separately.

Virtual environments are not exclusive to Windows, but the commands to use them can differ a bit across operating
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy