Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add venv to install instructions page #3960

Merged
merged 8 commits into from
Aug 21, 2023
Merged
28 changes: 25 additions & 3 deletions website/docs/docs/core/pip-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,36 @@ 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/).

<FAQ path="Core/install-pip-os-prereqs" />
<FAQ path="Core/install-python-compatibility" />
<FAQ path="Core/install-pip-best-practices" />

### Using virtual environments
We recommend using virtual environments to namespace pip modules. To create a new venv:
greg-mckeon marked this conversation as resolved.
Show resolved Hide resolved

```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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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. Reactivate the dbt virtual environment with every new session. When you install dbt in a virtual environment, you need to reactivate that same virtual environment each time you open a new shell window or session.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this up a bit to be shorter.


```shell
source dbt-env/bin/activate # activate the environment for Mac and Linux OR
dbt-env\Scripts\activate # activate the environment for Windows
```

:::tip
greg-mckeon marked this conversation as resolved.
Show resolved Hide resolved
You can create an alias for the source command in your $HOME/.bashrc, $HOME/.zshrc, or whichever rc file your shell draws from.
greg-mckeon marked this conversation as resolved.
Show resolved Hide resolved

For example, add the following to your rc file, replacing <PATH_TO_VIRTUAL_ENV_CONFIG> with the path to your virtual environment configuration.

```shell
alias env_dbt='source <PATH_TO_VIRTUAL_ENV_CONFIG>/bin/activate'
```
:::
greg-mckeon marked this conversation as resolved.
Show resolved Hide resolved

### Installing the adapter
Once you know [which adapter](/docs/supported-data-platforms) you're using, you can install it as `dbt-<adapter>`. For example, if using Postgres:

```shell
Expand Down