@@ -63,6 +63,8 @@ abstraction in mathematics, abstraction in coding is a form of
6363constructive laziness: it simultaneously allows the mathematician to
6464achieve more and do less work.
6565
66+ .. _tools :
67+
6668Obtaining the right software tools
6769----------------------------------
6870
@@ -127,6 +129,8 @@ Python you use.
127129 which were introduced in Python 3.6, so the code will not work in earlier
128130 versions of Python.
129131
132+ .. _venv :
133+
130134Setting up a Python virtual environment
131135---------------------------------------
132136
@@ -191,24 +195,26 @@ there then open the `View` menu and select `Terminal` to make it appear.
191195
192196The most straightforward way to create a venv is on the terminal
193197command line, not from within Python itself. This is accomplished
194- using Python's :mod: `venv ` package. For example, to create a venv
195- called `my_venv ` on Windows, you would type:
198+ using Python's :mod: `venv ` package. The venv has to be given a name. You will
199+ want this to be short, but distinctive enough that you know which venv you are
200+ using. For example, to create a venv
201+ called `PoP_venv ` on Windows, you would type:
196202
197203.. code-block :: console
198204
199- > py -m venv my_venv
205+ > py -m venv PoP_venv
200206
201207 while on Mac or Linux you would type:
202208
203209.. code-block :: console
204210
205- $ python3 -m venv my_venv
211+ $ python3 -m venv PoP_venv
206212
207213 Don't forget that the `> ` or `$ ` stands for the command prompt: you don't
208- type it. This command will create the folder `my_venv ` and various
214+ type it. This command will create the folder `PoP_venv ` and various
209215subfolders containing things like the Python program itself and space
210216for any packages which you install in the venv. If there was already a
211- file or folder called `my_venv ` in the current folder then you'll get
217+ file or folder called `PoP_venv ` in the current folder then you'll get
212218an error, so make sure you choose a new name.
213219
214220.. note ::
@@ -218,7 +224,7 @@ an error, so make sure you choose a new name.
218224 multiple Python installations on your computer then you might end up
219225 running the wrong one. If this happens then you will need to type the full
220226 path to the Python you want to use (starting with `/ ` on Mac or Linux or
221- `\` on Windows). Once the venv is installed and activated, it will be
227+ `\\ ` on Windows). Once the venv is installed and activated, it will be
222228 sufficient to type `python ` as the venv will ensure that this is the
223229 correct version.
224230
@@ -229,7 +235,7 @@ again. In the bash or zsh shells you would type:
229235
230236.. code-block :: console
231237
232- $ rm -rf my_venv
238+ $ rm -rf PoP_venv
233239
234240 .. warning ::
235241
@@ -248,27 +254,27 @@ Linux you would type:
248254
249255.. code-block :: console
250256
251- $ source my_venv /bin/activate
257+ $ source PoP_venv /bin/activate
252258
253259 while using bash on Windows you would type:
254260
255261.. code-block :: console
256262
257- $ source my_venv /Scripts/activate
263+ $ source PoP_venv /Scripts/activate
258264
259265 If using PowerShell on Windows then you type:
260266
261267.. code-block :: powershell
262268
263- > .\my_venv \Scripts\activate.ps1
269+ > .\PoP_venv \Scripts\activate.ps1
264270
265271 Obviously, you would use the folder name of your venv instead of
266- `my_venv `. In either case, your command prompt will change to indicate
272+ `PoP_venv `. In either case, your command prompt will change to indicate
267273that you are now using the venv. It might look something like:
268274
269275.. code-block :: console
270276
271- (my_venv ) $
277+ (PoP_venv ) $
272278
273279 Any subsequent invocations of Python commands such as `python3 ` will
274280now use the version from the venv, with access to whatever packages
@@ -285,8 +291,16 @@ for the correct activation command.
285291
286292 > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
287293
288- For further information, see :doc: `the official Python venv documentation
289- <library/venv>`.
294+ .. only :: not book
295+
296+ For further information, see :doc: `the official Python venv documentation
297+ <library/venv>`.
298+
299+ .. only :: book
300+
301+ For further information, see the official Python venv documentation.
302+ [#venv ]_
303+
290304
291305.. hint ::
292306
@@ -305,13 +319,13 @@ Python package :doc:`Pip <pip:index>`, which you will usually find
305319pre-installed in your Python installation. Pip has many usage options, which
306320enable a large number of different installation configurations. However, for
307321most users most of the time, a few simple pip commands suffice. As with
308- :term: ` venv ` creation, package installation is best accomplished from the
322+ venv creation, package installation is best accomplished from the
309323terminal and not from within Python itself. Don't forget to activate the venv!
310324
311325.. _install-from-pypi :
312326
313327Installing packages from PyPI
314- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328+ .............................
315329
316330`PyPI <https://pypi.org >`__ is the Python Package Index. It is the
317331official download location for publicly released Python packages which
@@ -324,7 +338,7 @@ terminal command:
324338
325339.. code-block :: console
326340
327- (my_venv ) $ python -m pip install numpy
341+ (PoP_venv ) $ python -m pip install numpy
328342
329343 It is also possible to invoke pip directly using the command `pip3 `,
330344but there are some circumstances where that might result in pip using
@@ -338,7 +352,7 @@ Pip can also be used to upgrade a package to the latest version:
338352
339353.. code-block :: console
340354
341- (my_venv ) $ python -m pip install --upgrade numpy
355+ (PoP_venv ) $ python -m pip install --upgrade numpy
342356
343357 Glossary
344358--------
@@ -389,3 +403,10 @@ Glossary
389403.. :ref:`Live Share instructions <vscode-liveshare>`.
390404.. Ensure that each of you can start a Live Share session and have the other
391405.. successfully join, and that all of you can edit files.
406+
407+ .. only :: book
408+
409+ .. rubric :: Footnotes
410+
411+ .. [#venv ] `https://docs.python.org/3/library/venv.html
412+ <https://docs.python.org/3/library/venv.html> `__
0 commit comments