From 280cbfcc3dceb08aae07f6528c40719e3024ab0d Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 13:50:19 -0400 Subject: [PATCH 01/13] build out doc --- docs/program/python-venv.md | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 docs/program/python-venv.md diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md new file mode 100644 index 0000000000..81447fb107 --- /dev/null +++ b/docs/program/python-venv.md @@ -0,0 +1,76 @@ +--- +title: "Prepare your Python Virtual Environment" +linkTitle: "Viam with your Python Virtualenv" +weight: 50 +type: "docs" +description: "Prepare your Python Virtual Environment to program robots with the Python SDK." +images: ["/services/icons/sdk.svg"] +tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "venv"] +--- + +To manage Python packages for your Viam application, you should use a virtual environment, or `venv`. +By using a `venv`, you can install Python packages just within the virtual environment, and not globally, which could mess with other projects or cause issues within your system. + +Follow this guide to set up a fresh virtual environment and install the Python SDK as a requirement for your application. + +## Setup your project + +First, create a directory to house your project. +For example, name your directory `viam-python`: + +```bash +mkdir viam-python +cd viam-python +``` + +## Create a Virtual Environment + +Now that you are in the project directory, create and activate a virtual environment for Python to run in. + +> **INFO** +> Creating a virtual environment (`venv`) is important as it isolates this python environment from any other you might already have. +This allows you to ensure a clean project and easier dependency management, as well as not bloating your global python environment. + +```bash +python3 -m venv viam-env +source viam-env/bin/activate +``` + +Now, you should see `(viam-env)` prepend the commands in your terminal window. +This shows that the python packages being used are from this particular environment. + +You can exit this environment by running `deactivate`. + +## Install Viam + +Inside the activated `viam-env` python environment, you can now install the Viam SDK: + +```bash +pip3 install viam-sdk +``` + +This will install Viam and all required dependencies. + +Should you need to install your own requirements, be sure to do so in this virtual environment. +You can [make a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt and include all necessary packages within, then install the requirements for your client application using `pip install -r requirements.txt`. + +## Setup your IDE + +You'll now want to point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter. + +The following steps are for VS Code. +If you're not using VS Code, please read your IDE's documentation on selecting python interpreters. + +1. Open the `viam-python` directory in VS Code +1. Open the Command Palette (using `⇧⌘P` or through the menus View -> Command Palette) +1. Select the command `Python: Select Interpreter`. +There, you should see all the interpreters available to you. +You're looking for one the on you just made: `viam-env`. +It will look something like: `Python 3.11.5 ('viam-env': venv) ./viam-env/bin/python`. +If you don't see it, click the `Refresh` icon on the top right of the Command Palette. + +Your IDE will now recognize all packages installed in this environment. + +## Start building + +You are now ready to start using Viam's Python SDK! From 25b6eb9d627598a420413ea1deb59d184a712a70 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 13:54:28 -0400 Subject: [PATCH 02/13] Apply suggestions from code review --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index 81447fb107..c1e01539cf 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -9,7 +9,7 @@ tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "ven --- To manage Python packages for your Viam application, you should use a virtual environment, or `venv`. -By using a `venv`, you can install Python packages just within the virtual environment, and not globally, which could mess with other projects or cause issues within your system. +By using a `venv`, you can install Python packages like Viam's client SDK just within the virtual environment, and not globally, which could mess with other projects or cause issues within your system. Follow this guide to set up a fresh virtual environment and install the Python SDK as a requirement for your application. From 7131926d997e6e8c2086737d56bcf6c5d990c806 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 14:18:42 -0400 Subject: [PATCH 03/13] Apply suggestions from code review --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index c1e01539cf..cedfcb2002 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -1,6 +1,6 @@ --- title: "Prepare your Python Virtual Environment" -linkTitle: "Viam with your Python Virtualenv" +linkTitle: "Prepare your Python Virtualenv for Viam" weight: 50 type: "docs" description: "Prepare your Python Virtual Environment to program robots with the Python SDK." From 6b38f8572ba0886c718c90ac8affedaeceaa757f Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 14:20:34 -0400 Subject: [PATCH 04/13] Apply suggestions from code review --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index cedfcb2002..5e4eda511d 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -11,7 +11,7 @@ tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "ven To manage Python packages for your Viam application, you should use a virtual environment, or `venv`. By using a `venv`, you can install Python packages like Viam's client SDK just within the virtual environment, and not globally, which could mess with other projects or cause issues within your system. -Follow this guide to set up a fresh virtual environment and install the Python SDK as a requirement for your application. +Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your application. ## Setup your project From 4029b75839662fb19543dd8a49a110e4942299f9 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 14:20:54 -0400 Subject: [PATCH 05/13] Apply suggestions from code review --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index 5e4eda511d..575410ac8b 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -11,7 +11,7 @@ tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "ven To manage Python packages for your Viam application, you should use a virtual environment, or `venv`. By using a `venv`, you can install Python packages like Viam's client SDK just within the virtual environment, and not globally, which could mess with other projects or cause issues within your system. -Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your application. +Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your Viam client application. ## Setup your project From 69a6d43e8b08a92a229a4fa4a9a18ef0fdd7bc7e Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 14:32:40 -0400 Subject: [PATCH 06/13] Apply suggestions from code review --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index 575410ac8b..1a0bedcf1c 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -3,7 +3,7 @@ title: "Prepare your Python Virtual Environment" linkTitle: "Prepare your Python Virtualenv for Viam" weight: 50 type: "docs" -description: "Prepare your Python Virtual Environment to program robots with the Python SDK." +description: "Prepare your Python Virtual Environment to program machines with the Python SDK." images: ["/services/icons/sdk.svg"] tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "venv"] --- From 5b010857cab6b151ee1bbb7514cef4bdf30ef4a3 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 14:52:38 -0400 Subject: [PATCH 07/13] Apply suggestions from code review Co-authored-by: Matt Vella <1242958+mcvella@users.noreply.github.com> --- docs/program/python-venv.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index 1a0bedcf1c..f2d58425a0 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -8,8 +8,8 @@ images: ["/services/icons/sdk.svg"] tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "venv"] --- -To manage Python packages for your Viam application, you should use a virtual environment, or `venv`. -By using a `venv`, you can install Python packages like Viam's client SDK just within the virtual environment, and not globally, which could mess with other projects or cause issues within your system. +To manage Python packages for your Viam application, it is recommended that you use a virtual environment, or `venv`. +By using a `venv`, you can install Python packages like Viam's client SDK just within the virtual environment, and not globally, which could cause conflicts with other projects or cause issues within your system. Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your Viam client application. From 83ced0f57487849f63c4cc58ca4d76fb2245e4ad Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 16:10:03 -0400 Subject: [PATCH 08/13] Apply suggestions from code review Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> --- docs/program/python-venv.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index f2d58425a0..a7dda5b045 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -65,8 +65,8 @@ If you're not using VS Code, please read your IDE's documentation on selecting p 1. Open the Command Palette (using `⇧⌘P` or through the menus View -> Command Palette) 1. Select the command `Python: Select Interpreter`. There, you should see all the interpreters available to you. -You're looking for one the on you just made: `viam-env`. -It will look something like: `Python 3.11.5 ('viam-env': venv) ./viam-env/bin/python`. +You're looking for the on you just made: `viam-env`. +It will look something like: `Python 3.XX.X ('viam-env': venv) ./viam-env/bin/python`. If you don't see it, click the `Refresh` icon on the top right of the Command Palette. Your IDE will now recognize all packages installed in this environment. From 9a363f084cd00ee2cee68307242830763ef80edd Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 14 Sep 2023 16:11:10 -0400 Subject: [PATCH 09/13] Apply suggestions from code review Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index a7dda5b045..23e4e19233 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -52,7 +52,7 @@ pip3 install viam-sdk This will install Viam and all required dependencies. Should you need to install your own requirements, be sure to do so in this virtual environment. -You can [make a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt and include all necessary packages within, then install the requirements for your client application using `pip install -r requirements.txt`. +You can [create a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt with all the packages you need and then install the requirements for your client application by running `pip install -r requirements.txt`. ## Setup your IDE From 0411cdd4785217d9e06626551b83c59188104c72 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Fri, 15 Sep 2023 09:34:58 -0400 Subject: [PATCH 10/13] Update python-venv.md --- docs/program/python-venv.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index 23e4e19233..d7b2ab6312 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -1,7 +1,7 @@ --- title: "Prepare your Python Virtual Environment" linkTitle: "Prepare your Python Virtualenv for Viam" -weight: 50 +weight: 10 type: "docs" description: "Prepare your Python Virtual Environment to program machines with the Python SDK." images: ["/services/icons/sdk.svg"] @@ -23,22 +23,16 @@ mkdir viam-python cd viam-python ``` -## Create a Virtual Environment +## Create and Activate a Virtual Environment Now that you are in the project directory, create and activate a virtual environment for Python to run in. -> **INFO** -> Creating a virtual environment (`venv`) is important as it isolates this python environment from any other you might already have. -This allows you to ensure a clean project and easier dependency management, as well as not bloating your global python environment. - ```bash python3 -m venv viam-env source viam-env/bin/activate ``` -Now, you should see `(viam-env)` prepend the commands in your terminal window. -This shows that the python packages being used are from this particular environment. - +Now, `(viam-env)` prepends the commands in your terminal window to indicate the Python packages being used are from this particular environment. You can exit this environment by running `deactivate`. ## Install Viam @@ -52,7 +46,7 @@ pip3 install viam-sdk This will install Viam and all required dependencies. Should you need to install your own requirements, be sure to do so in this virtual environment. -You can [create a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt with all the packages you need and then install the requirements for your client application by running `pip install -r requirements.txt`. +If you have more requirements, you can [create a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt with all the packages you need and then install the requirements for your client application by running `pip3 install -r requirements.txt`. ## Setup your IDE From f680ff83906bda24981071e0ae408ca987c4debf Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Fri, 15 Sep 2023 09:37:14 -0400 Subject: [PATCH 11/13] Apply suggestions from code review Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> --- docs/program/python-venv.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index d7b2ab6312..d4d1cb90b7 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -15,10 +15,10 @@ Follow this guide to set up a fresh virtual environment on your working computer ## Setup your project -First, create a directory to house your project. +First, create a directory for your project. For example, name your directory `viam-python`: -```bash +```sh {class="command-line" data-prompt="$"} mkdir viam-python cd viam-python ``` @@ -50,7 +50,7 @@ If you have more requirements, you can [create a](https://openclassrooms.com/en/ ## Setup your IDE -You'll now want to point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter. +Now, point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter. The following steps are for VS Code. If you're not using VS Code, please read your IDE's documentation on selecting python interpreters. @@ -62,6 +62,7 @@ There, you should see all the interpreters available to you. You're looking for the on you just made: `viam-env`. It will look something like: `Python 3.XX.X ('viam-env': venv) ./viam-env/bin/python`. If you don't see it, click the `Refresh` icon on the top right of the Command Palette. +Select the `viam-env` interpreter. Your IDE will now recognize all packages installed in this environment. From 3d36ed91ef9ed7c01c1bd6e47eaabe54f27a15f5 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Fri, 15 Sep 2023 09:38:49 -0400 Subject: [PATCH 12/13] Apply suggestions from code review --- docs/program/python-venv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index d4d1cb90b7..cbe50e7b73 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -68,4 +68,4 @@ Your IDE will now recognize all packages installed in this environment. ## Start building -You are now ready to start using Viam's Python SDK! +You are now ready to [start using Viam's Python SDK](/program/)! From a8992fcde2bb3a72c7be0506eedf2bc6cc572e2d Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Fri, 15 Sep 2023 14:44:37 -0400 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> --- docs/program/python-venv.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/program/python-venv.md b/docs/program/python-venv.md index cbe50e7b73..e7649ccb14 100644 --- a/docs/program/python-venv.md +++ b/docs/program/python-venv.md @@ -1,6 +1,6 @@ --- title: "Prepare your Python Virtual Environment" -linkTitle: "Prepare your Python Virtualenv for Viam" +linkTitle: "Prepare Virtualenv" weight: 10 type: "docs" description: "Prepare your Python Virtual Environment to program machines with the Python SDK." @@ -9,7 +9,7 @@ tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "ven --- To manage Python packages for your Viam application, it is recommended that you use a virtual environment, or `venv`. -By using a `venv`, you can install Python packages like Viam's client SDK just within the virtual environment, and not globally, which could cause conflicts with other projects or cause issues within your system. +By using a `venv`, you can install Python packages like Viam's client SDK within a virtual environment, avoiding conflicts with other projects or your system. Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your Viam client application. @@ -25,7 +25,7 @@ cd viam-python ## Create and Activate a Virtual Environment -Now that you are in the project directory, create and activate a virtual environment for Python to run in. +In the project directory, create and activate a virtual environment for Python to run in. ```bash python3 -m venv viam-env @@ -43,14 +43,14 @@ Inside the activated `viam-env` python environment, you can now install the Viam pip3 install viam-sdk ``` -This will install Viam and all required dependencies. +This installs Viam and all required dependencies. -Should you need to install your own requirements, be sure to do so in this virtual environment. -If you have more requirements, you can [create a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt with all the packages you need and then install the requirements for your client application by running `pip3 install -r requirements.txt`. +If you need to install your own requirements, also install them in this virtual environment. +To make your required packages easier to install in the future, you can also [create a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) requirements.txt file with a list of all the packages you need and then install the requirements for your client application by running `pip3 install -r requirements.txt`. ## Setup your IDE -Now, point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter. +If you would like to be able to use the environment you created with your IDE, point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter. The following steps are for VS Code. If you're not using VS Code, please read your IDE's documentation on selecting python interpreters.