Skip to content

Commit

Permalink
DOCS-1489: Change Python virtual environment string (#2670)
Browse files Browse the repository at this point in the history
  • Loading branch information
JessamyT authored Mar 18, 2024
1 parent c3ba6fc commit 1d26a08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/build/program/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Next, to install your preferred Viam SDK on your Linux or macOS development mach
If you are using the Python SDK, [set up a virtual environment](/build/program/python-venv/) to package the SDK inside before running your code, avoiding conflicts with other projects or your system.

```sh {class="command-line" data-prompt="$"}
python3 -m venv .venv
source .venv/bin/activate
pip install viam-sdk
```

Expand Down
22 changes: 11 additions & 11 deletions docs/build/program/python-venv.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Follow this guide to set up a fresh virtual environment on your working computer
python3 -m pip install --user virtualenv
```

## Setup your project
## Set up your project

First, create a directory for your project.
For example, name your directory `viam-python`:
Expand All @@ -48,16 +48,16 @@ cd viam-python
In the project directory, create and activate a virtual environment for Python to run in.

```sh {class="command-line" data-prompt="$"}
python3 -m venv viam-env
source viam-env/bin/activate
python3 -m venv .venv
source .venv/bin/activate
```

Now, `(viam-env)` prepends the commands in your terminal window to indicate the Python packages being used are from this particular environment.
Now, `.venv` 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

Inside the activated `viam-env` python environment, you can now install the Viam Python SDK:
Inside the activated `.venv` Python environment, you can now install the Viam Python SDK:

```sh {class="command-line" data-prompt="$"}
pip3 install viam-sdk
Expand All @@ -78,21 +78,21 @@ You can also run this command on an existing Python SDK install to add support f
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) <file>requirements.txt</file> 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
## Set up your IDE

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.
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.
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 the on you just made: `viam-env`.
It will look something like: `Python 3.XX.X ('viam-env': venv) ./viam-env/bin/python`.
You're looking for the on you just made: `.venv`.
It will look something like: `Python 3.XX.X ('.venv': venv) ./.venv/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.
Select the `.venv` interpreter.

Your IDE will now recognize all packages installed in this environment.

Expand Down

0 comments on commit 1d26a08

Please sign in to comment.