aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar discretegames <[email protected]>2022-11-05 17:09:15 -0700
committerGravatar discretegames <[email protected]>2022-11-05 17:09:15 -0700
commit3668202153652244adeb356f0201bf155b87205b (patch)
tree993fa8e9095f0a60c693d481f559c135f95e0f52 /pydis_site
parentfinal tweaks to ms store article (diff)
Redid windows guide titles/slugs/descriptions to be consistent with planned changes and have nice order
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/windows/common-issues.md (renamed from pydis_site/apps/content/resources/guides/python-guides/windows/common-windows-issues.md)94
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/windows/creating-python-environment-windows.md60
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/windows/installing-python.md (renamed from pydis_site/apps/content/resources/guides/python-guides/windows/install-on-windows.md)10
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/windows/putting-python-on-path.md6
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/windows/py-launcher.md (renamed from pydis_site/apps/content/resources/guides/python-guides/windows/python-on-windows.md)16
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/windows/unix-env-on-windows.md71
6 files changed, 143 insertions, 114 deletions
diff --git a/pydis_site/apps/content/resources/guides/python-guides/windows/common-windows-issues.md b/pydis_site/apps/content/resources/guides/python-guides/windows/common-issues.md
index 0bdb11ef..9a09319a 100644
--- a/pydis_site/apps/content/resources/guides/python-guides/windows/common-windows-issues.md
+++ b/pydis_site/apps/content/resources/guides/python-guides/windows/common-issues.md
@@ -1,8 +1,10 @@
---
title: Common issues using Python on Windows
-description: This guide describes common issues you may run into when using Python on Windows and how to fix them.
+description: A list of common issues with Python on Windows and how to fix them
---
+TODO!!! rewrite/rearrange in list form with lots of links to other resources
+
### When I run `python` in the terminal I get no result, or the Windows Store opens!
By default Windows has an alias for `python` in the terminal to guide you to
@@ -34,7 +36,7 @@ on that.
### I `pip` installed a package but when running my code get a `ModuleNotFoundError`
-* #### Are you actually getting a `ModuleNotFoundError`?
+- #### Are you actually getting a `ModuleNotFoundError`?
If you are using a code editor such as VSCode or Pycharm you may get a
squiggly line under your import saying the module couldn't be found, it is
@@ -48,30 +50,28 @@ on that.
[our guide on virtual environments](./python-on-windows.md#virtual-environments)
for more information.
-* #### Was the install successful?
+- #### Was the install successful?
Look out for errors when installing the module you want. If you get an
error, that's probably why the import isn't working, so you should look
into it. Often a google search will help with this.
-* #### Did you use the correct module name?
+- #### Did you use the correct module name?
Double check that you haven't made a typo in the name you are importing, or
in what you installed from PyPI, you need to make sure you type the name
exactly as it should be.
- Also, **the name you should `import` may not be the same as the name you `pip
- install`**. Check the module's documentation or PyPI page if you are unsure.
+ Also, **the name you should `import` may not be the same as the name you `pip install`**. Check the module's documentation or PyPI page if you are unsure.
Examples of this are:
- * [**opencv-python**](https://pypi.org/project/opencv-python/): You need to
- `pip install opencv-python`, but the import has to be `import cv2`
- * [**discord.py**](https://pypi.org/project/discord.py/): You need to `pip
- install discord.py`, but the import has to be `import discord`
- * [**python-dotenv**](https://pypi.org/project/python-dotenv/): You need to
- `pip install python-dotenv`, but the import has to be `import dotenv`
+ - [**opencv-python**](https://pypi.org/project/opencv-python/): You need to
+ `pip install opencv-python`, but the import has to be `import cv2`
+ - [**discord.py**](https://pypi.org/project/discord.py/): You need to `pip install discord.py`, but the import has to be `import discord`
+ - [**python-dotenv**](https://pypi.org/project/python-dotenv/): You need to
+ `pip install python-dotenv`, but the import has to be `import dotenv`
-* #### Are you installing to the same environment you're running your code from?
+- #### Are you installing to the same environment you're running your code from?
This is a very common issue. When you install a module from PyPI, you will
install it into a single Python environment, the one that the `pip` you
@@ -92,49 +92,49 @@ on that.
###### I installed the module using pip from the command line
- Run `pip -V` and look at the path returned it should be in the form
- `<PATH_TO_PYTHON>\Lib\site-packages\pip`.
+ Run `pip -V` and look at the path returned it should be in the form
+ `<PATH_TO_PYTHON>\Lib\site-packages\pip`.
- Then put `import sys;print(sys.executable);sys.exit(0)` at the top
- (above imports!) of your python file, and run it. The result should be
- in the form `<PATH_TO_PYTHON>\python.exe`.
+ Then put `import sys;print(sys.executable);sys.exit(0)` at the top
+ (above imports!) of your python file, and run it. The result should be
+ in the form `<PATH_TO_PYTHON>\python.exe`.
- Now compare that `PATH_TO_PYTHON` to the one from `pip -V`. If they're
- different, this is the cause of the `ModuleNotFoundError`. Follow the
- relevant "I'm running my code with ..." section below for how to fix
- this.
+ Now compare that `PATH_TO_PYTHON` to the one from `pip -V`. If they're
+ different, this is the cause of the `ModuleNotFoundError`. Follow the
+ relevant "I'm running my code with ..." section below for how to fix
+ this.
###### I'm running my code with `python` from the terminal.
- If you are using a virtual environment, ensure you have activated it before
- running `pip install`. You can test this by running `pip -V` and checking
- the path is the one of your virtual environment.
+ If you are using a virtual environment, ensure you have activated it before
+ running `pip install`. You can test this by running `pip -V` and checking
+ the path is the one of your virtual environment.
- Alternatively, you can use the `py` command to specify the python version
- you want to pip install into, e.g. `py -3.9 -m pip install numpy`, and to
- specify the executable you want to run your code with, e.g. `py -3.9
- my_script.py`.
+ Alternatively, you can use the `py` command to specify the python version
+ you want to pip install into, e.g. `py -3.9 -m pip install numpy`, and to
+ specify the executable you want to run your code with, e.g. `py -3.9
+ my_script.py`.
- If your `pip` and `python` commands are referring to different python
- environments at the same time, it's possible your PATH is configured
- incorrectly. See our
- [guide for adding Python to PATH](../python-on-windows.md#adding-python-to-your-path)
- for how to fix this.
+ If your `pip` and `python` commands are referring to different python
+ environments at the same time, it's possible your PATH is configured
+ incorrectly. See our
+ [guide for adding Python to PATH](../python-on-windows.md#adding-python-to-your-path)
+ for how to fix this.
###### I'm running my code with the button in VSCode
- To run your code from the same environment you installed Python to, set
- the interpreter to the one at the path you found when running `pip -V`
- by following
- [this guide](https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment).
- The path should be in the form `PATH_TO_PYTHON\python.exe`
+ To run your code from the same environment you installed Python to, set
+ the interpreter to the one at the path you found when running `pip -V`
+ by following
+ [this guide](https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment).
+ The path should be in the form `PATH_TO_PYTHON\python.exe`
- Alternatively, you can pip install to the currently activated
- environment. If you have configured VSCode to use a virtual environment,
- it should automatically activate it when you open a new terminal, so
- running the `pip install` command in the VSCode terminal should work. If
- you are not using a virtual environment, you can use the `py` launcher
- to specify the installation you want to install to.
+ Alternatively, you can pip install to the currently activated
+ environment. If you have configured VSCode to use a virtual environment,
+ it should automatically activate it when you open a new terminal, so
+ running the `pip install` command in the VSCode terminal should work. If
+ you are not using a virtual environment, you can use the `py` launcher
+ to specify the installation you want to install to.
### I `pip` installed a command line program but it isn't recognised
@@ -142,7 +142,7 @@ You pip installed a command line program like `PyInstaller` or `black` that is
intended to be run from the command line, but it does not work. Two common causes
for this are:
-* You are using Python from the Microsoft Store
+- You are using Python from the Microsoft Store
To check if this is the case, type `pip -V`. If the path output includes
something like
@@ -152,7 +152,7 @@ for this are:
Microsoft Store Python and install Python properly with the online
installer.
-* You manually modified your PATH Environment Variable incorrectly
+- You manually modified your PATH Environment Variable incorrectly
If you added `Python` to PATH manually through environment variables, it is
possible that you only added the executable but not the `/Scripts` folder.
diff --git a/pydis_site/apps/content/resources/guides/python-guides/windows/creating-python-environment-windows.md b/pydis_site/apps/content/resources/guides/python-guides/windows/creating-python-environment-windows.md
deleted file mode 100644
index 1c654cad..00000000
--- a/pydis_site/apps/content/resources/guides/python-guides/windows/creating-python-environment-windows.md
+++ /dev/null
@@ -1,60 +0,0 @@
----
-title: Creating a Unix-style Python Environment on Windows
-description: How to setup a Unix style Python Environment ready to start coding in
----
-
-Many programmers use Linux or macOS operating systems for their work, though newcomers to programming will likely want to get started on the computer they already own, which will often be running Windows.
-
-Programmers need to become comfortable using a command prompt (also known as a terminal), and many guides for both beginning and advanced programming will often tell you certain commands to run.
-The Windows command prompt has different names for similar commands that are available on Linux and macOS.
-This guide will also help you set up a command prompt called Git Bash, which will support many of the commands available on Linux and macOS.
-
-## Installing Python
-First you'll need to install Python. We recommend installing from the Python website, you can follow our guide on how to do this [here](../install-on-windows.md).
-
-## Installing a text editor
-You will also need a text editor for writing Python programs, and for subsequent steps of this guide.
-Powerful programs called integrated development environments (IDEs) like PyCharm and Visual Studio Code contain text editors, but they also contain many other features with uses that aren't immediately obvious to new programmers.
-
-[Notepad++](https://notepad-plus-plus.org/) is a popular text editor for both beginners and advanced users who prefer a simpler interface.
-Other editors we recommend can be found [here](https://pythondiscord.com/resources/tools/#editors).
-
-## Installing Git Bash
-Git is a command line program that helps you keep track of changes to your code, among other things.
-Many developers use it, and while you may not need it right away, it is useful to install it because it comes with Git Bash.
-On the "Select Components" screen, no settings need to be changed.
-The next screen will ask what text editor you want to use with Git. Vim is the default choice, though Vim is widely considered difficult to learn, so you may choose to select Notepad++ or whichever text editor you may have installed previously.
-
-For all remaining screens in the installation, the default selections are fine.
-
-## Configuring .bashrc
-`.bashrc` is a file where we tell Git Bash where the Python executable is.
-First, open Git Bash, and as your first command, type `echo ~` and hit enter.
-This will most likely print `c/Users/YourUsername` to the terminal.
-Navigate to this location in your file explorer, though keep in mind that Windows will display `c/Users/YourUsername` as `C:\Users\YourUsername`.
-In this folder, there will be a file called `.bashrc`; open it with your text editor of choice.
-
-For this step, you will need to remember where you installed Python earlier.
-In whichever folder that was, there is a file called `python.exe`; this is the executable that will run your Python programs.
-Copy the full path of this file, starting from `C:`.
-If you used the example location given earlier, it will be located at `C:\Python\python.exe`.
-
-In the `.bashrc` file, add a line to the end of the file saying `alias python='C:\\Python\\python.exe`, where `C:\\Python\\python.exe` is the location of your `python.exe` file, but each folder is separated by two backslashes instead of one.
-The two backslashes are because a single backslash is used as an [escape character](https://en.wikipedia.org/wiki/Escape_character).
-Save the file, and then type `source ~/.bashrc` to activate the change you have made.
-
-Finally, enter `python -c 'import sys; print(sys.executable)'` into Git Bash.
-(If you attempt to copy and paste this into the terminal using Ctrl+V, it might not work, though Shift+Insert will.)
-If all the steps have been followed correctly, this will print the location of your `python.exe` file and demonstrate that your environment is set up correctly.
-You can hereafter use the `python` command in Git Bash to run any Python program that you write.
-
-## Running a test program
-At any location on your computer, create a file named `hello.py` and open it with your text editor.
-The program need only be one line: `print('Hello world!')`.
-Save this file.
-
-To run this program in Git Bash, navigate to where it is saved on your hard drive.
-If you know the path to this location, you can use the `cd` command ("cd" stands for "change directory") to navigate to it.
-If it's saved to your desktop, `cd /c/Users/YourUsername/Desktop` will take you there.
-Otherwise if you have the directory open in your file explorer, you can right click anywhere in the white space of the file explorer window (not on top of a file) and select "Git Bash Here".
-Once you're there, type `python hello.py`, and the program will run.
diff --git a/pydis_site/apps/content/resources/guides/python-guides/windows/install-on-windows.md b/pydis_site/apps/content/resources/guides/python-guides/windows/installing-python.md
index 2422e024..09c82865 100644
--- a/pydis_site/apps/content/resources/guides/python-guides/windows/install-on-windows.md
+++ b/pydis_site/apps/content/resources/guides/python-guides/windows/installing-python.md
@@ -1,6 +1,6 @@
---
title: Installing Python on Windows
-description: How to properly install python on windows
+description: How we recommend installing Python on Windows
---
The recommended way to install Python on windows is directly from the
@@ -9,12 +9,14 @@ Installing Python from the Microsoft Store is not recommended as it can
[cause issues](../microsoft-store.md).
## Selecting an Installer
+
There are many different installer options available from the downloads page.
You should usually select the "Windows installer" option instead of the "Windows
embeddable package". Some minor versions may not
### Which version?
-Current Python versions follow the form `3.major.minor`. Major releases happen
+
+Current Python versions follow the form `3.minor.micro`. Major releases happen
yearly and provide new features and breaking changes, whilst minor releases are
more common and only include bug/security fixes.
@@ -28,6 +30,7 @@ You should generally always install the newest minor version, although some may
not provide an installer in which case you should find the newest that does.
### 32-bit vs 64-bit?
+
Install 64-bit python unless you have reason not to. With 32 bit you may run
into memory limits if doing intensive operations (Python will be limited to
using 4GB of memory), and some installed modules may not offer prebuilt wheels
@@ -41,6 +44,7 @@ Specifications". It should say "64-bit operating system, x64-based processor" if
you have support. You need a 64 bit processor and OS to install 64 bit programs.
## Running the installer
+
When you run the installer you should see a screen like this:
![python_installer_screen](https://user-images.githubusercontent.com/22353562/126144479-cfe6bd98-6d2e-47c3-b6b3-5de9f2656e9a.png)
@@ -56,7 +60,7 @@ If you installed Python without adding to PATH and now want to add it, see
Then simply click install, and wait for the install to finish!
To test your installation, type "cmd" in the windows search bar and select
-"Command Prompt" to open a terminal (make sure it's opened *after* installation
+"Command Prompt" to open a terminal (make sure it's opened _after_ installation
has finished) type `python -V`, and press enter. If it outputs your python
version, you've successfully installed Python. (if you didn't add to PATH, you
can use [the py launcher](../python-on-windows.md#the-py-launcher) to test
diff --git a/pydis_site/apps/content/resources/guides/python-guides/windows/putting-python-on-path.md b/pydis_site/apps/content/resources/guides/python-guides/windows/putting-python-on-path.md
new file mode 100644
index 00000000..25bf8d8f
--- /dev/null
+++ b/pydis_site/apps/content/resources/guides/python-guides/windows/putting-python-on-path.md
@@ -0,0 +1,6 @@
+---
+title: Putting Python on Path
+description: How to make sure Python is properly on the Windows Path environment variable
+---
+
+TODO!!!
diff --git a/pydis_site/apps/content/resources/guides/python-guides/windows/python-on-windows.md b/pydis_site/apps/content/resources/guides/python-guides/windows/py-launcher.md
index 76ca0bc7..416d13ec 100644
--- a/pydis_site/apps/content/resources/guides/python-guides/windows/python-on-windows.md
+++ b/pydis_site/apps/content/resources/guides/python-guides/windows/py-launcher.md
@@ -1,9 +1,12 @@
---
-title: Python on Windows
-description: This guide explains how manage your Python installation(s) on Windows
+title: The py Launcher on Windows
+description: Common commands and usage of the 'py' Python launcher
---
+TODO!!! rewrite/rearrange to be all about the py command
+
## The py launcher
+
By default, Python installed on Windows using the online Python installer comes
with the "py launcher". It is a command line tool you invoke using the `py`
command, and helps you invoke a specific python version.
@@ -21,6 +24,7 @@ The versions will be ordered from newest to oldest, and the `*` will indicate
which version running `py` will call by default. This depends on the following
requirements, and may not be the same version you get from running `python` (if
you get any):
+
```text
If an exact version is not given, using the latest version can be overridden by
any of the following, (in priority order):
@@ -31,6 +35,7 @@ any of the following, (in priority order):
• From [defaults] in py.ini in your %LOCALAPPDATA%\py.ini
• From [defaults] in py.ini beside py.exe (use `where py` to locate)
```
+
You can override which version is called by specifying the major and minor
versions to used. For example, to invoke python 3.7, you could run `py -3.7`.
You can then pass any arguments to `python` on top of that, for example
@@ -61,6 +66,7 @@ Here's a [VSCode tutorial](https://code.visualstudio.com/docs/python/environment
dependencies and virtual environments.
## Changing PATH
+
PATH is the system variable that Windows uses to locate executables needed on
the command line. Whenever you type a command name in your terminal, for example
`python` or `pip`, the terminal will look it up in the PATH to try and find out
@@ -69,6 +75,7 @@ what executable that command refers to, so it can be run.
The Python installer provides an option to add `python` to your PATH, although it
is not checked by default so many people miss it. Don't worry if you forgot to select
this though, you can add it after installing:
+
### The safe method: through the installer
The easiest and and safest way to add Python to PATH is by rerunning the installer.
@@ -121,8 +128,9 @@ For a standard Python install the file path should look something like
this two the path you should add two folders, the one containing `python.exe`,
and the `Scripts/` directory in that directory. In this case the two paths would
be:
-- C:\Users\username\AppData\Local\Programs\Python\Python3xx\
-- C:\Users\username\AppData\Local\Programs\Python\Python3xx\Scripts
+
+- C:\Users\username\AppData\Local\Programs\Python\Python3xx\
+- C:\Users\username\AppData\Local\Programs\Python\Python3xx\Scripts
It is important that both paths are added, otherwise `pip` and other commands
will not work correctly.
diff --git a/pydis_site/apps/content/resources/guides/python-guides/windows/unix-env-on-windows.md b/pydis_site/apps/content/resources/guides/python-guides/windows/unix-env-on-windows.md
new file mode 100644
index 00000000..28322f7c
--- /dev/null
+++ b/pydis_site/apps/content/resources/guides/python-guides/windows/unix-env-on-windows.md
@@ -0,0 +1,71 @@
+---
+title: Setting up a Unix-style Python Environment on Windows
+description: How to setup a Unix-style Python environment ready to start coding in
+---
+
+<!-- TODO? Mention WSL2? -->
+
+Many programmers use Linux or macOS operating systems for their work, though newcomers to programming will likely want
+to get started on the computer they already own, which will often be running Windows.
+
+Programmers need to become comfortable using a command prompt (also known as a terminal or shell), and many guides for
+both beginning and advanced programming will often tell you certain commands to run. The Windows command prompt has
+different names for similar commands that are available on Linux and macOS. This guide will also help you set up a
+command prompt called Git Bash, which will support many of the commands available on Linux and macOS.
+
+## Installing Python
+
+First you'll need to install Python. We recommend installing from the Python website, you can follow our guide on how to
+do this [here](../install-on-windows.md).
+
+## Installing a text editor
+
+You will also need a text editor for writing Python programs, and for subsequent steps of this guide. Powerful programs
+called integrated development environments (IDEs) like PyCharm and Visual Studio Code contain text editors, but they
+also contain many other features with uses that aren't immediately obvious to new programmers.
+
+[Notepad++](https://notepad-plus-plus.org/) is a popular text editor for both beginners and advanced users who prefer a
+simpler interface. Other editors we recommend can be found [here](https://pythondiscord.com/resources/tools/#editors).
+
+## Installing Git Bash
+
+Git is a command line program that helps you keep track of changes to your code, among other things. Many developers use
+it, and while you may not need it right away, it is useful to install it because it comes with Git Bash. On the "Select
+Components" screen, no settings need to be changed. The next screen will ask what text editor you want to use with Git.
+Vim is the default choice, though Vim is widely considered difficult to learn, so you may choose to select Notepad++ or
+whichever text editor you may have installed previously.
+
+For all remaining screens in the installation, the default selections are fine.
+
+## Configuring .bashrc
+
+`.bashrc` is a file where we tell Git Bash where the Python executable is. First, open Git Bash, and as your first
+command, type `echo ~` and hit enter. This will most likely print `c/Users/YourUsername` to the terminal. Navigate to
+this location in your file explorer, though keep in mind that Windows will display `c/Users/YourUsername` as
+`C:\Users\YourUsername`. In this folder, there will be a file called `.bashrc`; open it with your text editor of choice.
+
+For this step, you will need to remember where you installed Python earlier. In whichever folder that was, there is a
+file called `python.exe`; this is the executable that will run your Python programs. Copy the full path of this file,
+starting from `C:`. If you used the example location given earlier, it will be located at `C:\Python\python.exe`.
+
+In the `.bashrc` file, add a line to the end of the file saying `alias python='C:\\Python\\python.exe`, where
+`C:\\Python\\python.exe` is the location of your `python.exe` file, but each folder is separated by two backslashes
+instead of one. The two backslashes are because a single backslash is used as an [escape
+character](https://en.wikipedia.org/wiki/Escape_character). Save the file, and then type `source ~/.bashrc` to activate
+the change you have made.
+
+Finally, enter `python -c 'import sys; print(sys.executable)'` into Git Bash. (If you attempt to copy and paste this
+into the terminal using Ctrl+V, it might not work, though Shift+Insert will.) If all the steps have been followed
+correctly, this will print the location of your `python.exe` file and demonstrate that your environment is set up
+correctly. You can hereafter use the `python` command in Git Bash to run any Python program that you write.
+
+## Running a test program
+
+At any location on your computer, create a file named `hello.py` and open it with your text editor. The program need
+only be one line: `print('Hello world!')`. Save this file.
+
+To run this program in Git Bash, navigate to where it is saved on your hard drive. If you know the path to this
+location, you can use the `cd` command ("cd" stands for "change directory") to navigate to it. If it's saved to your
+desktop, `cd /c/Users/YourUsername/Desktop` will take you there. Otherwise if you have the directory open in your file
+explorer, you can right click anywhere in the white space of the file explorer window (not on top of a file) and select
+"Git Bash Here". Once you're there, type `python hello.py`, and the program will run.