From ab59bdd7c35c93562ed2cb74ebff1969fad9ef6f Mon Sep 17 00:00:00 2001 From: Greg McKeon Date: Mon, 21 Aug 2023 11:30:13 -0400 Subject: [PATCH 1/6] Add venv to install instructions page --- website/docs/docs/core/pip-install.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 26a15d8ad37..24e32511537 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -5,14 +5,32 @@ description: "You can use pip to install dbt Core and adapter plugins from the c You need to use `pip` to install dbt Core on Windows or Linux operating systems. You can use `pip` or [Homebrew](/docs/core/homebrew-install) for installing dbt Core on a MacOS. -You can install dbt Core and plugins using `pip` because they are Python modules distributed on [PyPI](https://pypi.org/project/dbt/). We recommend using virtual environments when installing with `pip`. - +You can install dbt Core and plugins using `pip` because they are Python modules distributed on [PyPI](https://pypi.org/project/dbt/). - +### Using virtual environments +We recommend using virtual environments to namespace pip modules. To create a new venv: + +```shell +python3 -m venv dbt-env # create the environment +``` + +If you install dbt in a virtual environment, you need to reactivate that same virtual environment each time you create a shell window or session. + +```shell +source dbt-env/bin/activate # activate the environment for Mac and Linux OR +dbt-env\Scripts\activate # activate the environment for Windows +``` + +:::tip +You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever rc file your shell draws from. + +For example, you can add a command like alias env_dbt='source /bin/activate', replacing with the path to your virtual environment configuration. +::: +### Installing the adapter Once you know [which adapter](/docs/supported-data-platforms) you're using, you can install it as `dbt-`. For example, if using Postgres: ```shell From 2eff755ab5d47c31449295c0e066e1230c0f8414 Mon Sep 17 00:00:00 2001 From: Greg McKeon Date: Mon, 21 Aug 2023 12:25:15 -0400 Subject: [PATCH 2/6] Update pip-install.md add code snippet --- website/docs/docs/core/pip-install.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 24e32511537..f5ffbe46e27 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -27,7 +27,11 @@ dbt-env\Scripts\activate # activate the environment for Windows :::tip You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever rc file your shell draws from. -For example, you can add a command like alias env_dbt='source /bin/activate', replacing with the path to your virtual environment configuration. +For example, add the following, replacing with the path to your virtual environment configuration. + +```shell +alias env_dbt='source /bin/activate' +``` ::: ### Installing the adapter From 935ddaa3d18a4cd17f0485fd6cf4c4e7573943ce Mon Sep 17 00:00:00 2001 From: Greg McKeon Date: Mon, 21 Aug 2023 13:49:15 -0400 Subject: [PATCH 3/6] Update pip-install.md --- website/docs/docs/core/pip-install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index f5ffbe46e27..c86acc9857f 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -27,7 +27,7 @@ dbt-env\Scripts\activate # activate the environment for Windows :::tip You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever rc file your shell draws from. -For example, add the following, replacing with the path to your virtual environment configuration. +For example, add the following to your rc file, replacing with the path to your virtual environment configuration. ```shell alias env_dbt='source /bin/activate' From 82f34a81b0c9a49a9cd486edb2fad2af1e208405 Mon Sep 17 00:00:00 2001 From: Greg McKeon Date: Mon, 21 Aug 2023 16:25:34 -0400 Subject: [PATCH 4/6] Update pip-install.md --- website/docs/docs/core/pip-install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index c86acc9857f..e109413b0ab 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -17,7 +17,7 @@ We recommend using virtual environments to namespace pip modules. To create a ne python3 -m venv dbt-env # create the environment ``` -If you install dbt in a virtual environment, you need to reactivate that same virtual environment each time you create a shell window or session. +2. Activate that same virtual environment each time you create a shell window or session: ```shell source dbt-env/bin/activate # activate the environment for Mac and Linux OR From 2dcf368e38344c587e4d3e80f35ad001fa999745 Mon Sep 17 00:00:00 2001 From: Greg McKeon Date: Mon, 21 Aug 2023 16:26:15 -0400 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com> --- website/docs/docs/core/pip-install.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index e109413b0ab..78a4057d430 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -11,7 +11,9 @@ You can install dbt Core and plugins using `pip` because they are Python modules ### Using virtual environments -We recommend using virtual environments to namespace pip modules. To create a new venv: +We recommend using virtual environments (venv) to namespace pip modules. + +1. Create a new venv: ```shell python3 -m venv dbt-env # create the environment @@ -24,15 +26,14 @@ source dbt-env/bin/activate # activate the environment for Mac and Linux OR dbt-env\Scripts\activate # activate the environment for Windows ``` -:::tip -You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever rc file your shell draws from. +#### Create an alias +You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever config file your shell draws from. For example, add the following to your rc file, replacing with the path to your virtual environment configuration. ```shell alias env_dbt='source /bin/activate' ``` -::: ### Installing the adapter Once you know [which adapter](/docs/supported-data-platforms) you're using, you can install it as `dbt-`. For example, if using Postgres: From 037d5313936c68df324f5c2a205ee037ac5a22b1 Mon Sep 17 00:00:00 2001 From: "Leona B. Campbell" <3880403+runleonarun@users.noreply.github.com> Date: Mon, 21 Aug 2023 14:09:29 -0700 Subject: [PATCH 6/6] Update website/docs/docs/core/pip-install.md --- website/docs/docs/core/pip-install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 78a4057d430..a35ad5f0d77 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -27,7 +27,7 @@ dbt-env\Scripts\activate # activate the environment for Windows ``` #### Create an alias -You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever config file your shell draws from. +To activate your dbt environment with every new shell window or session, you can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever config file your shell draws from. For example, add the following to your rc file, replacing with the path to your virtual environment configuration.