From ecd9bd0eefe963fb61dbfdef9fe4fb61fdd85b94 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 31 Dec 2020 22:06:37 +0000 Subject: First draft of env explaintions --- bot/resources/tags/enviroments.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 bot/resources/tags/enviroments.md diff --git a/bot/resources/tags/enviroments.md b/bot/resources/tags/enviroments.md new file mode 100644 index 000000000..c4356254e --- /dev/null +++ b/bot/resources/tags/enviroments.md @@ -0,0 +1,18 @@ +**Python Enviroments** + +The main purpose of Python [virtual environments](https://docs.python.org/3/library/venv.html#venv-def) is to create an isolated environment for Python projects. This means that each project can have its own dependencies, such as third party packages installed using `pip`, regardless of what dependencies every other project has. + +To see the current enviroment in use by python you can run: +```py +>>> import sys +>>> print(sys.executable) +/usr/bin/python3 +``` + +To see the enviroment in use by `pip` you can do `pip debug`, or `pip3 debug` for linux/macOS. The 3rd line of the output will contain the path in use. I.E. `sys.executable: /usr/bin/python3` + +If the python's `sys.executable` doesn't match pip's then they are currently using different enviroments! 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 enviroment. + +Further reading: +• [Real Python's primer on Python Virtual Environments](https://realpython.com/python-virtual-environments-a-primer) +• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) \ No newline at end of file -- cgit v1.2.3 From 1066212190138529385a8f3bac27faa0ec97ccfa Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 31 Dec 2020 22:28:16 +0000 Subject: Fix linting by adding new line at eof --- bot/resources/tags/enviroments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/resources/tags/enviroments.md b/bot/resources/tags/enviroments.md index c4356254e..5b2914cd9 100644 --- a/bot/resources/tags/enviroments.md +++ b/bot/resources/tags/enviroments.md @@ -15,4 +15,4 @@ If the python's `sys.executable` doesn't match pip's then they are currently usi Further reading: • [Real Python's primer on Python Virtual Environments](https://realpython.com/python-virtual-environments-a-primer) -• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) \ No newline at end of file +• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) -- cgit v1.2.3 From 70fcbd1cdb742ff33ea6491b383bf2e65fe1b24f Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 31 Dec 2020 22:06:37 +0000 Subject: First draft of env explaintions --- bot/resources/tags/enviroments.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 bot/resources/tags/enviroments.md diff --git a/bot/resources/tags/enviroments.md b/bot/resources/tags/enviroments.md new file mode 100644 index 000000000..5b2914cd9 --- /dev/null +++ b/bot/resources/tags/enviroments.md @@ -0,0 +1,18 @@ +**Python Enviroments** + +The main purpose of Python [virtual environments](https://docs.python.org/3/library/venv.html#venv-def) is to create an isolated environment for Python projects. This means that each project can have its own dependencies, such as third party packages installed using `pip`, regardless of what dependencies every other project has. + +To see the current enviroment in use by python you can run: +```py +>>> import sys +>>> print(sys.executable) +/usr/bin/python3 +``` + +To see the enviroment in use by `pip` you can do `pip debug`, or `pip3 debug` for linux/macOS. The 3rd line of the output will contain the path in use. I.E. `sys.executable: /usr/bin/python3` + +If the python's `sys.executable` doesn't match pip's then they are currently using different enviroments! 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 enviroment. + +Further reading: +• [Real Python's primer on Python Virtual Environments](https://realpython.com/python-virtual-environments-a-primer) +• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) -- cgit v1.2.3 From 7f920229e0d8245b2778833f5089997d3d46432a Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 19 Jan 2021 20:31:01 +0000 Subject: grammar and spelling fixes --- bot/resources/tags/enviroments.md | 18 ------------------ bot/resources/tags/environments.md | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 bot/resources/tags/enviroments.md create mode 100644 bot/resources/tags/environments.md diff --git a/bot/resources/tags/enviroments.md b/bot/resources/tags/enviroments.md deleted file mode 100644 index 5b2914cd9..000000000 --- a/bot/resources/tags/enviroments.md +++ /dev/null @@ -1,18 +0,0 @@ -**Python Enviroments** - -The main purpose of Python [virtual environments](https://docs.python.org/3/library/venv.html#venv-def) is to create an isolated environment for Python projects. This means that each project can have its own dependencies, such as third party packages installed using `pip`, regardless of what dependencies every other project has. - -To see the current enviroment in use by python you can run: -```py ->>> import sys ->>> print(sys.executable) -/usr/bin/python3 -``` - -To see the enviroment in use by `pip` you can do `pip debug`, or `pip3 debug` for linux/macOS. The 3rd line of the output will contain the path in use. I.E. `sys.executable: /usr/bin/python3` - -If the python's `sys.executable` doesn't match pip's then they are currently using different enviroments! 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 enviroment. - -Further reading: -• [Real Python's primer on Python Virtual Environments](https://realpython.com/python-virtual-environments-a-primer) -• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md new file mode 100644 index 000000000..f8825f0dd --- /dev/null +++ b/bot/resources/tags/environments.md @@ -0,0 +1,18 @@ +**Python Environments** + +The main purpose of Python [virtual environments](https://docs.Python.org/3/library/venv.html#venv-def) is to create an isolated environment for Python projects. This means that each project can have its own dependencies, such as third party packages installed using pip, regardless of what dependencies every other project has. + +To see the current environment in use by Python, you can run: +```py +>>> import sys +>>> print(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: +• [Python Virtual Environments: A Primer](https://realPython.com/Python-virtual-environments-a-primer) +• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) -- cgit v1.2.3 From ab3e40356602a0a2a4404db61949e7570d029464 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 19 Jan 2021 21:25:37 +0000 Subject: Fix url --- bot/resources/tags/environments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md index f8825f0dd..f97873770 100644 --- a/bot/resources/tags/environments.md +++ b/bot/resources/tags/environments.md @@ -14,5 +14,5 @@ To see the environment in use by pip, you can do `pip debug` (`pip3 debug` for L 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: -• [Python Virtual Environments: A Primer](https://realPython.com/Python-virtual-environments-a-primer) +• [Python Virtual Environments: A Primer](https://realpython.com/python-virtual-environments-a-primer) • [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) -- cgit v1.2.3 From 84a5afe4c28f037e070722e1f48f9ae80493f0fa Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 19 Jan 2021 21:35:13 +0000 Subject: Add a section on why to use a virtual env --- bot/resources/tags/environments.md | 15 ++++++++++++--- 1 file 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) -- cgit v1.2.3 From fddde4c27ab0a75d861a42535b52986aae7ca429 Mon Sep 17 00:00:00 2001 From: ChrisJL Date: Wed, 20 Jan 2021 10:40:11 +0000 Subject: Apply suggestions from code review Grammar Co-authored-by: Mark --- bot/resources/tags/environments.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md index df04b2770..51d1b4a20 100644 --- a/bot/resources/tags/environments.md +++ b/bot/resources/tags/environments.md @@ -9,9 +9,9 @@ To see the current environment in use by Python, you can run: /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. +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. **Why use a virtual environment?** -- cgit v1.2.3 From 04e64c523df212815eb4b29d766f83916a3dd099 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 20 Jan 2021 10:41:20 +0000 Subject: Remove incorrect point --- bot/resources/tags/environments.md | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md index 51d1b4a20..7bc69bde4 100644 --- a/bot/resources/tags/environments.md +++ b/bot/resources/tags/environments.md @@ -17,7 +17,6 @@ If Python's `sys.executable` doesn't match pip's, then they are currently using • 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. -- cgit v1.2.3