From a298b32a9587008c8f7b6a355759ee7ed25e546a Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Tue, 17 Dec 2024 14:11:04 +0000 Subject: [PATCH 01/21] Create a Python virtual environment --- .../create-a-python-virtual-environment.md | 72 +++++++++++++++++++ website/sidebars.js | 1 + 2 files changed, 73 insertions(+) create mode 100644 website/docs/docs/core/create-a-python-virtual-environment.md diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md new file mode 100644 index 00000000000..185addc15b0 --- /dev/null +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -0,0 +1,72 @@ +--- +title: Create a Python Virtual Environment +id: create-a-python-virtual-environment +description: "Instructions on creating a Python virtual environment." +pagination_next: "docs/core/create-a-python-virtual-environment" +pagination_prev: null +--- + +A Python virtual environment is an isolated workspace for Python projects. This prevents libraries and versions used in one project from interfering with others, making it especially helpful when working on multiple projects with differing requirements or avoiding conflicts with global Python installations. + +The Python ecosystem offers several tools for creating isolated environments, such as [conda](https://anaconda.org/anaconda/conda), [poetry](https://python-poetry.org/docs/managing-environments/), and `venv`. Among these, `venv` has the fewest additional dependencies and has been included by default in recent Python versions for quite some time. + +`venv` will set up a Python virtual environment within the `.venv` folder. + +Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. + + +## Prerequisites + +- Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. +- Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. +- Access to a terminal or command prompt. +- Have the necessary permissions to create directories and install packages on your machine. + +## Install a Python virtual environment + +Depending on the operating system you use, you'll need to execute specific steps to set up a virtual environment. + +To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder named `venv`: + + + +1. Create your virtual environment + +```shell +python3 -m venv .venv +``` + +2. Activate your virtual environment: + +```shell +source .venv/bin/activate +which python +.venv/bin/python +``` + + + + +1. Create your virtual environment + +```shell +py -m venv .venv +``` + +2. Activate your virtual environment: + +```shell +.venv\Scripts\activate +where python +.venv\Scripts\python +``` + + + +## Deactivate virtual environment + +To switch projects or leave your virtual environment, deactivate the environment using the command while the virtual environment is active: + +```shell +deactivate +``` diff --git a/website/sidebars.js b/website/sidebars.js index 5600fe164f2..834051136ff 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -191,6 +191,7 @@ const sidebarSettings = { label: "Install dbt Core", link: { type: "doc", id: "docs/core/installation-overview" }, items: [ + "docs/core/create-a-python-virtual-environment", "docs/core/installation-overview", "docs/core/pip-install", "docs/core/docker-install", From 7c8942659c617f856b4cb364f61eddbc24850e2b Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:16:52 +0000 Subject: [PATCH 02/21] Update website/docs/docs/core/create-a-python-virtual-environment.md Co-authored-by: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 185addc15b0..74e548703d9 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -1,5 +1,5 @@ --- -title: Create a Python Virtual Environment +title: Create a Python virtual environment id: create-a-python-virtual-environment description: "Instructions on creating a Python virtual environment." pagination_next: "docs/core/create-a-python-virtual-environment" From 544cce2aed124311cdc3d589aba1f8c21761f15e Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Fri, 20 Dec 2024 19:44:37 +0000 Subject: [PATCH 03/21] Added tabs --- .../create-a-python-virtual-environment.md | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 185addc15b0..5f14e4e96e8 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -17,9 +17,9 @@ Users who want to run dbt locally, for example in [dbt Core](/docs/core/installa ## Prerequisites +- Access to a terminal or command prompt. - Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. - Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. -- Access to a terminal or command prompt. - Have the necessary permissions to create directories and install packages on your machine. ## Install a Python virtual environment @@ -28,40 +28,43 @@ Depending on the operating system you use, you'll need to execute specific steps To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder named `venv`: - + + + 1. Create your virtual environment -1. Create your virtual environment + ```shell + python3 -m venv .venv + ``` -```shell -python3 -m venv .venv -``` + 2. Activate your virtual environment: -2. Activate your virtual environment: + ```shell + source .venv/bin/activate + which python + .venv/bin/python + ``` + -```shell -source .venv/bin/activate -which python -.venv/bin/python -``` - + + 1. Create your virtual environment - + ```shell + py -m venv .venv + ``` -1. Create your virtual environment + 2. Activate your virtual environment: -```shell -py -m venv .venv -``` - -2. Activate your virtual environment: + ```shell + .venv\Scripts\activate + where python + .venv\Scripts\python + ``` + + -```shell -.venv\Scripts\activate -where python -.venv\Scripts\python -``` +If you're using dbt Core, refer to [What are the best practices for installing dbt Core with pip?](/faqs/Core/install-pip-best-practices.md#using-virtual-environments) after creating your virtual environment. - +If you're using the dbt Cloud CLI, you can [install dbt Cloud CLI in pip](/docs/cloud/cloud-cli-installation#install-dbt-cloud-cli-in-pip) after creating your virtual environment. ## Deactivate virtual environment From 4fd2cd2b67df0f570205eb1f68d51a3d3645217f Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:05:03 +0000 Subject: [PATCH 04/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 18f548f4b9d..086d3f32648 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -26,7 +26,7 @@ Users who want to run dbt locally, for example in [dbt Core](/docs/core/installa Depending on the operating system you use, you'll need to execute specific steps to set up a virtual environment. -To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder named `venv`: +To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder which you can name it anything you want. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` From 75c8a35bc8ece2faaae50417e97f3b02ef0aa1d2 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:06:06 +0000 Subject: [PATCH 05/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 086d3f32648..974dff5c9a5 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -10,7 +10,7 @@ A Python virtual environment is an isolated workspace for Python projects. This The Python ecosystem offers several tools for creating isolated environments, such as [conda](https://anaconda.org/anaconda/conda), [poetry](https://python-poetry.org/docs/managing-environments/), and `venv`. Among these, `venv` has the fewest additional dependencies and has been included by default in recent Python versions for quite some time. -`venv` will set up a Python virtual environment within the `.venv` folder. +`venv` will set up a Python virtual environment within the `env` folder. Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. From 5ecbad2118e9250117f01f9480da35584ecdfd03 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:06:35 +0000 Subject: [PATCH 06/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 974dff5c9a5..43012bfd8ba 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -33,7 +33,7 @@ To install a Python virtual environment, navigate to your project directory and 1. Create your virtual environment ```shell - python3 -m venv .venv + python3 -m venv env ``` 2. Activate your virtual environment: From 749d9b85ae15047538b01ab960327682e279f4d0 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:07:12 +0000 Subject: [PATCH 07/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 43012bfd8ba..3d91fb4603d 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -39,7 +39,7 @@ To install a Python virtual environment, navigate to your project directory and 2. Activate your virtual environment: ```shell - source .venv/bin/activate + source env/bin/activate which python .venv/bin/python ``` From 322359d00dc7591e0629cf20db356b414c327b26 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:07:32 +0000 Subject: [PATCH 08/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 3d91fb4603d..791462ebf4c 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -41,7 +41,7 @@ To install a Python virtual environment, navigate to your project directory and ```shell source env/bin/activate which python - .venv/bin/python + env/bin/python ``` From 867ccfc24b9238fc9fedd3110fbc1a2ea737a52d Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:07:50 +0000 Subject: [PATCH 09/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 791462ebf4c..15892a057d8 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -49,7 +49,7 @@ To install a Python virtual environment, navigate to your project directory and 1. Create your virtual environment ```shell - py -m venv .venv + py -m venv env ``` 2. Activate your virtual environment: From e16c8bfa30401c96cf2e9e264ea85d81a0f0374f Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:08:13 +0000 Subject: [PATCH 10/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 15892a057d8..b2f4027d75a 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -55,7 +55,7 @@ To install a Python virtual environment, navigate to your project directory and 2. Activate your virtual environment: ```shell - .venv\Scripts\activate + env\Scripts\activate where python .venv\Scripts\python ``` From 46222c3fad7b7b93660d9df91bbabf5a5f95548f Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:08:36 +0000 Subject: [PATCH 11/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index b2f4027d75a..262cb436d26 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -57,7 +57,7 @@ To install a Python virtual environment, navigate to your project directory and ```shell env\Scripts\activate where python - .venv\Scripts\python + env\Scripts\python ``` From bc1fcb7e7a853c62c5f8229cc0a34e8644c98933 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Mon, 30 Dec 2024 12:22:11 +0000 Subject: [PATCH 12/21] rendered examples --- .../create-a-python-virtual-environment.md | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 262cb436d26..2c9f900ccaf 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -30,7 +30,7 @@ To install a Python virtual environment, navigate to your project directory and - 1. Create your virtual environment + 1. Create your virtual environment: ```shell python3 -m venv env @@ -40,7 +40,17 @@ To install a Python virtual environment, navigate to your project directory and ```shell source env/bin/activate + ``` + + 3. Verify Python Path: + + ```shell which python + ``` + + 4. Run Python: + + ```shell env/bin/python ``` @@ -56,7 +66,17 @@ To install a Python virtual environment, navigate to your project directory and ```shell env\Scripts\activate + ``` + + 3. Verify Python Path: + + ```shell where python + ``` + + 4. Run Python: + + ```shell env\Scripts\python ``` From b0f3b613d5d7665974ffb8d26b9369f80e1ff7d7 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:38:29 +0000 Subject: [PATCH 13/21] Update website/docs/docs/core/create-a-python-virtual-environment.md --- website/docs/docs/core/create-a-python-virtual-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md index 2c9f900ccaf..e696353e445 100644 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ b/website/docs/docs/core/create-a-python-virtual-environment.md @@ -26,7 +26,7 @@ Users who want to run dbt locally, for example in [dbt Core](/docs/core/installa Depending on the operating system you use, you'll need to execute specific steps to set up a virtual environment. -To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder which you can name it anything you want. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` +To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder that you can name anything. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` From 65346ff1b73aa0cea9b34b48c73c5bd54617e492 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Fri, 24 Jan 2025 11:02:51 +0000 Subject: [PATCH 14/21] Updated PR --- .../create-a-python-virtual-environment.md | 95 ------------------- website/docs/docs/core/pip-install.md | 92 ++++++++++++++++-- website/package-lock.json | 42 ++++---- website/sidebars.js | 3 +- 4 files changed, 109 insertions(+), 123 deletions(-) delete mode 100644 website/docs/docs/core/create-a-python-virtual-environment.md diff --git a/website/docs/docs/core/create-a-python-virtual-environment.md b/website/docs/docs/core/create-a-python-virtual-environment.md deleted file mode 100644 index e696353e445..00000000000 --- a/website/docs/docs/core/create-a-python-virtual-environment.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: Create a Python virtual environment -id: create-a-python-virtual-environment -description: "Instructions on creating a Python virtual environment." -pagination_next: "docs/core/create-a-python-virtual-environment" -pagination_prev: null ---- - -A Python virtual environment is an isolated workspace for Python projects. This prevents libraries and versions used in one project from interfering with others, making it especially helpful when working on multiple projects with differing requirements or avoiding conflicts with global Python installations. - -The Python ecosystem offers several tools for creating isolated environments, such as [conda](https://anaconda.org/anaconda/conda), [poetry](https://python-poetry.org/docs/managing-environments/), and `venv`. Among these, `venv` has the fewest additional dependencies and has been included by default in recent Python versions for quite some time. - -`venv` will set up a Python virtual environment within the `env` folder. - -Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. - - -## Prerequisites - -- Access to a terminal or command prompt. -- Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. -- Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. -- Have the necessary permissions to create directories and install packages on your machine. - -## Install a Python virtual environment - -Depending on the operating system you use, you'll need to execute specific steps to set up a virtual environment. - -To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder that you can name anything. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` - - - - 1. Create your virtual environment: - - ```shell - python3 -m venv env - ``` - - 2. Activate your virtual environment: - - ```shell - source env/bin/activate - ``` - - 3. Verify Python Path: - - ```shell - which python - ``` - - 4. Run Python: - - ```shell - env/bin/python - ``` - - - - 1. Create your virtual environment - - ```shell - py -m venv env - ``` - - 2. Activate your virtual environment: - - ```shell - env\Scripts\activate - ``` - - 3. Verify Python Path: - - ```shell - where python - ``` - - 4. Run Python: - - ```shell - env\Scripts\python - ``` - - - -If you're using dbt Core, refer to [What are the best practices for installing dbt Core with pip?](/faqs/Core/install-pip-best-practices.md#using-virtual-environments) after creating your virtual environment. - -If you're using the dbt Cloud CLI, you can [install dbt Cloud CLI in pip](/docs/cloud/cloud-cli-installation#install-dbt-cloud-cli-in-pip) after creating your virtual environment. - -## Deactivate virtual environment - -To switch projects or leave your virtual environment, deactivate the environment using the command while the virtual environment is active: - -```shell -deactivate -``` diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 6ed9ca06f8e..b576a04e48c 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -10,24 +10,96 @@ You can install dbt Core and plugins using `pip` because they are Python modules -### Using virtual environments +## Create a Python virtual environment -We recommend using virtual environments (venv) to namespace pip modules. +A Python virtual environment is an isolated workspace for Python projects. This prevents libraries and versions used in one project from interfering with others, making it especially helpful when working on multiple projects with differing requirements or avoiding conflicts with global Python installations. -1. Create a new venv: +The Python ecosystem offers several tools for creating isolated environments, such as [conda](https://anaconda.org/anaconda/conda), [poetry](https://python-poetry.org/docs/managing-environments/), and `venv`. Among these, `venv` has the fewest additional dependencies and has been included by default in recent Python versions for quite some time. -```shell -python -m venv dbt-env # create the environment -``` +`venv` will set up a Python virtual environment within the `env` folder. + +Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. + +## Prerequisites + +- Access to a terminal or command prompt. +- Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. +- Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. +- Have the necessary permissions to create directories and install packages on your machine. + +## Install a Python virtual environment + +Depending on the operating system you use, you'll need to execute specific steps to set up a virtual environment. + +To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder that you can name anything. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` + + + + 1. Create your virtual environment: + + ```shell + python3 -m venv env + ``` + + 2. Activate your virtual environment: + + ```shell + source env/bin/activate + ``` + + 3. Verify Python Path: + + ```shell + which python + ``` + + 4. Run Python: + + ```shell + env/bin/python + ``` + + + + 1. Create your virtual environment + + ```shell + py -m venv env + ``` + + 2. Activate your virtual environment: + + ```shell + env\Scripts\activate + ``` + + 3. Verify Python Path: + + ```shell + where python + ``` + + 4. Run Python: + + ```shell + env\Scripts\python + ``` + + + +If you're using dbt Core, refer to [What are the best practices for installing dbt Core with pip?](/faqs/Core/install-pip-best-practices.md#using-virtual-environments) after creating your virtual environment. + +If you're using the dbt Cloud CLI, you can [install dbt Cloud CLI in pip](/docs/cloud/cloud-cli-installation#install-dbt-cloud-cli-in-pip) after creating your virtual environment. + +## Deactivate virtual environment -2. Activate that same virtual environment each time you create a shell window or session: +To switch projects or leave your virtual environment, deactivate the environment using the command while the virtual environment is active: ```shell -source dbt-env/bin/activate # activate the environment for Mac and Linux OR -dbt-env\Scripts\activate # activate the environment for Windows +deactivate ``` -#### Create an alias +### Create an alias 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. diff --git a/website/package-lock.json b/website/package-lock.json index 8d573ee3426..c3699b6c20d 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "website", "version": "0.0.0", "dependencies": { "@docusaurus/core": "3.4.0", @@ -4949,9 +4950,10 @@ } }, "node_modules/@stoplight/json-schema-viewer": { - "version": "4.16.2", - "resolved": "https://registry.npmjs.org/@stoplight/json-schema-viewer/-/json-schema-viewer-4.16.2.tgz", - "integrity": "sha512-sOODscuidOTk9OMbE41XO5zt7DjKn6eoS32VtC5SJ0TbRT2vXfYVc9wrHLeae2YsNjsh98Nh+LaquGF504Ye2Q==", + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@stoplight/json-schema-viewer/-/json-schema-viewer-4.16.4.tgz", + "integrity": "sha512-5+2mQIhoFFPzk1Gxb1khrVk2Y5BzEIGcNnY74Ky0mo1ipkSNLBWX5ALU8Kn1rTjVjgO8KHacqR4rw/ZaNhxwhQ==", + "license": "Apache-2.0", "dependencies": { "@stoplight/json": "^3.20.1", "@stoplight/json-schema-tree": "^4.0.0", @@ -9902,9 +9904,10 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -11840,9 +11843,10 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -11863,7 +11867,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -11878,6 +11882,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express/node_modules/content-disposition": { @@ -11905,9 +11913,10 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/express/node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" }, "node_modules/express/node_modules/range-parser": { "version": "1.2.1", @@ -21641,15 +21650,16 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, diff --git a/website/sidebars.js b/website/sidebars.js index 3134921a387..82cef68a7de 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -192,10 +192,9 @@ const sidebarSettings = { label: "Install dbt Core", link: { type: "doc", id: "docs/core/installation-overview" }, items: [ - "docs/core/create-a-python-virtual-environment", + "docs/core/docker-install", "docs/core/installation-overview", "docs/core/pip-install", - "docs/core/docker-install", "docs/core/source-install", ], }, From f30f4cbbbf0097203d93eaae3253194ddb17f83d Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Fri, 24 Jan 2025 13:01:22 +0000 Subject: [PATCH 15/21] Update website/docs/docs/core/pip-install.md Co-authored-by: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> --- website/docs/docs/core/pip-install.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index b576a04e48c..0d10383b340 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -22,6 +22,8 @@ Users who want to run dbt locally, for example in [dbt Core](/docs/core/installa ## Prerequisites +Once you've met the prerequisites, follow these steps to set up your virtual environment. + - Access to a terminal or command prompt. - Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. - Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. From e987de6131651cc0968d3621129a1e2ce08ef302 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Fri, 24 Jan 2025 13:17:43 +0000 Subject: [PATCH 16/21] rolled in feedback --- website/docs/docs/core/pip-install.md | 16 ++++++++-------- website/sidebars.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 0d10383b340..67bebc6ae49 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -10,13 +10,11 @@ You can install dbt Core and plugins using `pip` because they are Python modules -## Create a Python virtual environment +## What is a Python virtual environment? -A Python virtual environment is an isolated workspace for Python projects. This prevents libraries and versions used in one project from interfering with others, making it especially helpful when working on multiple projects with differing requirements or avoiding conflicts with global Python installations. +A Python virtual environment creates an isolated workspace for Python projects, preventing conflicts between dependencies of different projects and versions. -The Python ecosystem offers several tools for creating isolated environments, such as [conda](https://anaconda.org/anaconda/conda), [poetry](https://python-poetry.org/docs/managing-environments/), and `venv`. Among these, `venv` has the fewest additional dependencies and has been included by default in recent Python versions for quite some time. - -`venv` will set up a Python virtual environment within the `env` folder. +You can create virtual environments using tools like conda, poetry, or venv. This guide uses venv because it's lightweight, has the fewest additional dependencies, and is included in Python by default. Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. @@ -29,11 +27,13 @@ Once you've met the prerequisites, follow these steps to set up your virtual env - Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. - Have the necessary permissions to create directories and install packages on your machine. -## Install a Python virtual environment +### Set up a Python virtual environment + +`venv` will set up a Python virtual environment within the `env` folder. Depending on the operating system you use, you'll need to execute specific steps to set up a virtual environment. -To install a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder that you can name anything. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` +To set up a Python virtual environment, navigate to your project directory and execute the command. This will generate a new virtual environment within a local folder that you can name anything. [Our convention](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#virtual-environments) has been to name it `env` or `env-anything-you-want` @@ -93,7 +93,7 @@ If you're using dbt Core, refer to [What are the best practices for installing d If you're using the dbt Cloud CLI, you can [install dbt Cloud CLI in pip](/docs/cloud/cloud-cli-installation#install-dbt-cloud-cli-in-pip) after creating your virtual environment. -## Deactivate virtual environment +### Deactivate virtual environment To switch projects or leave your virtual environment, deactivate the environment using the command while the virtual environment is active: diff --git a/website/sidebars.js b/website/sidebars.js index 82cef68a7de..49a3287f6ee 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -192,8 +192,8 @@ const sidebarSettings = { label: "Install dbt Core", link: { type: "doc", id: "docs/core/installation-overview" }, items: [ - "docs/core/docker-install", "docs/core/installation-overview", + "docs/core/docker-install", "docs/core/pip-install", "docs/core/source-install", ], From 8ee97f3fae259fd4e4b9d849fa08e72a8c5d3fbf Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Fri, 24 Jan 2025 13:23:07 +0000 Subject: [PATCH 17/21] added code blocks and webaite links --- 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 67bebc6ae49..7313391d62c 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -14,7 +14,7 @@ You can install dbt Core and plugins using `pip` because they are Python modules A Python virtual environment creates an isolated workspace for Python projects, preventing conflicts between dependencies of different projects and versions. -You can create virtual environments using tools like conda, poetry, or venv. This guide uses venv because it's lightweight, has the fewest additional dependencies, and is included in Python by default. +You can create virtual environments using tools like [conda](https://anaconda.org/anaconda/conda), [poetry](https://python-poetry.org/docs/managing-environments/) or `venv`. This guide uses `venv` because it's lightweight, has the fewest additional dependencies, and is included in Python by default. Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. From 4f1ae532f8f0fb7a64bff3fd995e797ef6b2a01f Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Fri, 24 Jan 2025 18:23:09 +0000 Subject: [PATCH 18/21] 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 7313391d62c..9e35ee92d84 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -18,7 +18,7 @@ You can create virtual environments using tools like [conda](https://anaconda.or Users who want to run dbt locally, for example in [dbt Core](/docs/core/installation-overview) or the [dbt Cloud CLI](/docs/cloud/cloud-cli-installation#install-a-virtual-environment) may want to install a Python virtual environment. -## Prerequisites +### Prerequisites Once you've met the prerequisites, follow these steps to set up your virtual environment. From 5d6322e4234199104abe20e1f55574f08bd17d18 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Mon, 27 Jan 2025 09:38:24 +0000 Subject: [PATCH 19/21] Amended Headers --- website/docs/docs/core/pip-install.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 9e35ee92d84..90c4a084e6e 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -111,7 +111,7 @@ For example, add the following to your rc file, replacing ` -### Installing prereleases +## Installing prereleases A prerelease adapter is a version released before the final, stable version. It allows users to test new features, provide feedback, and get early access to upcoming functionality — ensuring your system will be ready for the final release. @@ -266,7 +266,7 @@ dbt --version ``` Note, this will also install any pre-releases of all dependencies. -#### Activate your virtual environment +### Activate your virtual environment To install or use packages within your virtual environment: From 694f51e8811a16fdbe5a4dad98db857e1fc58534 Mon Sep 17 00:00:00 2001 From: nataliefiann <120089939+nataliefiann@users.noreply.github.com> Date: Mon, 27 Jan 2025 09:59:56 +0000 Subject: [PATCH 20/21] Update website/docs/docs/core/pip-install.md --- website/docs/docs/core/pip-install.md | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/docs/core/pip-install.md b/website/docs/docs/core/pip-install.md index 90c4a084e6e..fe13d83534c 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -20,7 +20,6 @@ Users who want to run dbt locally, for example in [dbt Core](/docs/core/installa ### Prerequisites -Once you've met the prerequisites, follow these steps to set up your virtual environment. - Access to a terminal or command prompt. - Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. From efb872528263502737c1c41e3f585312cedaad44 Mon Sep 17 00:00:00 2001 From: Natalie Fiann Date: Mon, 27 Jan 2025 10:02:09 +0000 Subject: [PATCH 21/21] Updated prerequisites --- 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 fe13d83534c..622eea01a7e 100644 --- a/website/docs/docs/core/pip-install.md +++ b/website/docs/docs/core/pip-install.md @@ -20,11 +20,11 @@ Users who want to run dbt locally, for example in [dbt Core](/docs/core/installa ### Prerequisites - - Access to a terminal or command prompt. - Have [Python](https://www.python.org/downloads/) installed on your machine. You can check if Python is installed by running `python --version` or `python3 --version` in your terminal or command prompt. - Have [pip installed](https://pip.pypa.io/en/stable/installation/). You can check if pip is installed by running `pip --version` or `pip3 --version`. - Have the necessary permissions to create directories and install packages on your machine. +- Once you've met the prerequisites, follow these steps to set up your virtual environment. ### Set up a Python virtual environment