aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-01-19 21:35:13 +0000
committerGravatar Chris <[email protected]>2021-01-19 21:35:13 +0000
commit84a5afe4c28f037e070722e1f48f9ae80493f0fa (patch)
tree17ecf1a0c0324ff53b70191604e4ef6a8a51374a
parentFix url (diff)
Add a section on why to use a virtual env
-rw-r--r--bot/resources/tags/environments.md15
1 files changed, 12 insertions, 3 deletions
diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md
index f97873770..df04b2770 100644
--- a/bot/resources/tags/environments.md
+++ b/bot/resources/tags/environments.md
@@ -6,13 +6,22 @@ To see the current environment in use by Python, you can run:
```py
>>> import sys
>>> print(sys.executable)
-/usr/bin/Python3
+/usr/bin/python3
```
-To see the environment in use by pip, you can do `pip debug` (`pip3 debug` for Linux/macOS). The 3rd line of the output will contain the path in use. e.g. `sys.executable: /usr/bin/Python3`.
+To see the environment in use by pip, you can do `pip debug` (`pip3 debug` for Linux/macOS). The 3rd line of the output will contain the path in use. e.g. `sys.executable: /usr/bin/python3`.
If Python's `sys.executable` doesn't match pip's then they are currently using different environments! This may cause Python to raise a `ModuleNotFoundError` when you try to use a package you just installed with pip, as it was installed to a different environment.
-Further reading:
+**Why use a virtual environment?**
+
+• Resolve dependency issues by allowing the use of different versions of a package for different projects. For example, you could use Package A v2.7 for Project X and Package A v1.3 for Project Y.
+• Make your project self-contained and reproducible by capturing all package dependencies in a requirements file. Try running `pip freeze` to see what you currently have installed!
+• Install packages on a host on which you do not have admin privileges.
+• Keep your global `site-packages/` directory tidy by removing the need to install packages system-wide which you might only need for one project.
+
+
+**Further reading:**
+
• [Python Virtual Environments: A Primer](https://realpython.com/python-virtual-environments-a-primer)
• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv)