# Using Python or Conda environments in the Jupyter App

We recommend all users to install Python packages within an environment. This can be a [Conda or a python virtual environment](/oscar/software/python-installs.md). Follow these steps to use such environments in the [Jupyter app](https://ood.ccv.brown.edu/pun/sys/dashboard/batch_connect/sys/bc_ccv_jupyter/session_contexts/new).

## Python Environments

### One Time Python Setup

1. Open a terminal on Oscar.
2. Load the relevant python module and create and/or activate the environment. See this page for more information about creating [virtual environments](https://docs.ccv.brown.edu/oscar/software/python-installs#using-virtualenv).
3. Run `pip install notebook` to install Jupyter notebook, if not already installed.
4. Run `pip install ipykernel` to install ipykernel in this environment.
5. Run `python -m ipykernel install --user --name=<myenv>` where `<myenv>` is the name of the environment.

### Launching Jupyter Notebook (Python Environments)

1. Open the "Basic Jupyter Notebook for Python Environments" app on the Open OnDemand interface
2. Under "Python Module on Oscar", choose the python module you loaded when the environment was created.
3. Under "Python Virtual Environment", add the name of the Virtual Environment you created. Note: If your virtual environment is not at the top level of your home directory, you should input the absolute path to the environment directory.
4. Under the "Modules" , enter the name of the python module used to create the environment. Add any additional modules you may need separated with a space.
5. Choose the other options as required.
6. Click "Launch" to start the job
7. Click "Connect to Jupyter" on the next screen.
8. To start a new notebook, click "New" -> \<myenv> where \<myenv> is the environment.
9. For starting a pre-existing notebook, open the notebook. In the Jupyter interface, click "Kernel" -> "Change Kernel" -> \<myenv> where myenv is the name of the environment.

## Conda Environments

### One Time Conda Setup

1. Open a terminal on Oscar.
2. Activate the conda environment.
3. Run `pip install notebook` to install Jupyter notebook, if not already installed.
4. Run `pip install ipykernel` to install ipykernel in this environment.
5. Run `python -m ipykernel install --user --name=<myenv>` where `<myenv>` is the name of the environment.

### Launching Jupyter Notebook (Conda)

1. Open the "Basic Jupyter Notebook with Anaconda" app on the Open OnDemand interface
2. Under "Oscar Anaconda module", choose "anaconda/2020.02"
3. Enter the name of the conda environment in "Conda Env"
4. Choose the other options as required.
5. Click "Launch" to start the job
6. Click "Connect to Jupyter" on the next screen.
7. To start a new notebook, click "New" -> \<myenv> where \<myenv> is the environment.
8. For starting a pre-existing notebook, open the notebook. In the Jupyter interface, click "Kernel" -> "Change Kernel" -> \<myenv> where myenv is the name of the environment.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ccv.brown.edu/oscar/connecting-to-oscar/open-ondemand/using-python-or-conda-environments-in-the-jupyter-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
