# How to automatically source default environment in new terminal?

**URL:** <https://discourse.jupyter.org/t/how-to-automatically-source-default-environment-in-new-terminal/26989>\
**Category:** JupyterLab\
**Created:** [July 16, 2024, 8:41am UTC](https://discourse.jupyter.org/t/how-to-automatically-source-default-environment-in-new-terminal/26989 "2024-07-16T08:41:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sona](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sona/32/4965_2.png) [@sona](https://discourse.jupyter.org/u/sona)\
**Post date:** [July 16, 2024, 8:41am UTC](https://discourse.jupyter.org/t/how-to-automatically-source-default-environment-in-new-terminal/26989/1 "2024-07-16T08:41:22Z")

</div>

I run JupyterLab installed in a particular environment. But that environment is not sourced automatically when a terminal is opened. Also `! pip install ...` inside a Python notebook, will probably use the wrong e.g. system wide pip instead of the one that belongs to the current kernel. Can I somehow customize that?

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [July 16, 2024, 4:34pm UTC](https://discourse.jupyter.org/t/how-to-automatically-source-default-environment-in-new-terminal/26989/2 "2024-07-16T16:34:33Z")

</div>

> [@sona](#):
>
> Also `! pip install ...` inside a Python notebook, will probably use the wrong e.g. system wide pip

This has not been the way since **2019**. You should be using the magic version, `%pip install`, inside a cell in a running notebook to do installs in an active running `.ipynb` file. That ensures the commands target the environment where the kernel backing the notebook is running. The exclamation point used in conjunction with install commands doesn’t do that and so it may lead to unexpected outcomes.  
Please, see [here](https://discourse.jupyter.org/t/jupyter-lab-notebook-no-module-named-error-upon-importing-installed-packages/26875/3) for more about this with links to related resources and documentation therein.
