> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring custom environments and sample projects

When you create a new project in Anaconda Enterprise, you must select a base environment for the project. Anaconda provides several base Anaconda environments, along with Python, R, or Hadoop-Spark environments for you to choose from.

If these environments do not suit your needs, you can create a custom environment, then include it in the list of environments that are available upon project creation.

## Preparing to create custom environments

<Warning>
  Custom environments must be created using a machine with platform architecture identical to your instance of Anaconda Enterprise.
</Warning>

1. Connect to the machine you are using to create environments.

2. If necessary, install the `bzip2` utility by running the following command:

   ```
   yum install bzip2
   ```

3. If necessary, install the `wget` utility by running the following command:

   ```
   yum install wget
   ```

4. If necessary, update or install miniconda.

   <AccordionGroup>
     <Accordion title="Update miniconda">
       Update miniconda by running the following commands:

       ```
       conda deactivate
       conda update -y --all
       conda update -y -n base -c defaults conda
       ```
     </Accordion>

     <Accordion title="Install miniconda">
       1. Create the directory for miniconda by running the following command:

          ```
          mkdir -p ~/miniconda3

          ```
       2. Download the miniconda installer and rename it `miniconda.sh` by running the following command:

          ```
          wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh

          ```
       3. Verify your checksum by running the following command:

          ```
          sha256sum ~/miniconda3/miniconda.sh

          ```
       4. Install miniconda by running the following command:

          ```
          bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3

          ```
       5. Remove the miniconda installer by running the following command:

          ```
          rm -rf ~/miniconda3/miniconda.sh

          ```
       6. View your Linux shell by running the following command:

          ```
          echo $SHELL

          ```
       7. Initialize miniconda by running the following command:

          ```
          # Replace <SHELL> with the return from the previous command
          ~/miniconda3/bin/conda init <SHELL>

          ```

          For example:

          ```
          ~/miniconda3/bin/conda init bash

          ```
     </Accordion>
   </AccordionGroup>

5. Create or clear your environments directory by running the following commands:

   <CodeGroup>
     ```sh Create directory theme={null}
     mkdir -p /opt/continuum/envs
     ```

     ```sh Clear directory theme={null}
     rm -rf /opt/continuum/envs/*
     ```
   </CodeGroup>

6. Clean the conda install by running the following command:

   ```
   conda clean -y --all --force-pkgs-dirs
   ```

7. Using your preferred file editor, open your `~/.bash_profile` file.

8. Add these two export commands to the end of the file to instruct conda to create all new environments in the `/opt/continuum/envs/` directory:

   ```
   export CONDA_ENVS_DIRS=/opt/continuum/envs
   export CONDA_PKGS_DIRS=/opt/continuum/envs/.pkgs
   ```

9. Save your work and close the file.

10. Apply your changes by running the following command:

    ```
    source ~/.bash_profile
    ```

## Creating a custom environment

1. Use conda to create or clone your custom environment:

   <Tabs>
     <Tab title="Create an environment">
       Create a conda environment by running the following command:

       ```
       # Replace <ENV> with a name for your new environment
       conda create -y -n <ENV> python=3.8 ipykernel
       ```

       <Tip>
         `python 3.8` and `ipykernel` are just examples. Create your environment using the packages you need!
       </Tip>
     </Tab>

     <Tab title="Clone an environment">
       Clone an existing environment by running the following command:

       ```
       # Replace <CLONE_ENV> with the name of the environment you want to clone
       # Replace <ENV> with a name for your new environment
       conda create -y --clone <CLONE_ENV> --name <ENV>
       ```
     </Tab>
   </Tabs>

2. Verify that your environment was created in the `/opt/continuum/envs` directory by running the following command:

   ```
   conda env list
   ```

3. Create an archive file containing the custom environment by running the following commands:

   ```
   # Replace <ENV> with the name of your environment
   cd /opt/continuum/envs
   tar cfj <ENV>.tar.bz2 .pkgs <ENV>
   ```

   <Note>
     Your archive file includes the directory that is named after your environment and the `.pkgs` directory.
   </Note>

For more help with creating environments using conda, see the [official conda documentation](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).

## Uploading your custom environment

1. Open a browser and log in to Anaconda Enterprise as a user with administrator permissions.

   <Tip>
     The `anaconda-enterprise` user account has these permissions.
   </Tip>

2. Open any existing project by clicking on it to view its settings.

3. If necessary, change the **Default Editor** to *JupyterLab*.

4. Open a session for the project.

5. Upload your environment archive file to the project.

   <Note>
     You may see a **Large File Size** warning. This can safely be ignored.
   </Note>

6. Open a terminal in your project session and unpack your environment archive file by running the following command:

   ```
   # Replace <ENV> with the name of your environment tarball file
   tar xfj /opt/continuum/project/<ENV>.tar.bz2 -C /opt/continuum/envs/

   ```

7. Verify your environment archive file unpacked successfully by running the following command:

   ```
   ls -laF /opt/continuum/envs

   ```

8. Delete the uploaded environment archive file from the project and stop the project session.

## Creating a project template archive

The project template archive file must contain, at a minimum, the `anaconda-project.yml` file. For more information and help building projects, see the official [Anaconda Project documentation](https://anaconda-project.readthedocs.io/en/latest/).

1. Connect to the machine you are using to create environments.

2. If necessary, create the project directory by running the following command:

   ```
   # Replace <PROJECT> with the name of your project
   mkdir -p '/opt/continuum/project/<PROJECT>'
   ```

3. Enter the directory you just created by running the following command:

   ```
   # Replace <PROJECT> with the name of your project
   cd /opt/continuum/project/<PROJECT>

   ```

4. Using your preferred file editor, create and populate an `anaconda-project.yml` file in your project directory. Save and close the file when complete.

   <Note>
     Your project’s `name:` will display on the **Sample Projects** grid *or* the **Environments** dropdown list after the project is created.
   </Note>

   <Accordion title="Example anaconda-project.yml">
     ```
     name: <PROJECT>

     description: <A_BRIEF_DESCRIPTION>

     packages:
           - python=3.8
           - ipykernel

     platforms:
           - linux-64

     env_specs:
           <ENV>: {}

     ```
   </Accordion>

5. Create an archive file for the project, then set permissions for it by running the following commands:

   ```
   # Replace <PROJECT> with your project name
   cd /opt/continuum/project
   tar cfj <PROJECT>.tar.bz2 <PROJECT>
   chmod 644 <PROJECT>.tar.bz2

   ```

   <Note>
     This archive file is the template that other projects will use as a starting point for their own projects.
   </Note>

## Creating a sample project

You must upload and move the project into the `/gallery` directory to display the project on the **Sample Projects** page.

1. Open a browser and log in to Anaconda Enterprise as a user with administrator permissions.

   <Tip>
     The `anaconda-enterprise` user account has these permissions.
   </Tip>

2. Click **Create +**, then select *Upload project*.

3. Upload your `<PROJECT>.tar.bz2` file to create the project.

4. View your project’s settings.

5. If necessary, change the **Default Editor** to *JupyterLab*.

6. Open a session for the new project.

7. Upload your project archive file to the new project.

   <Note>
     You may see a **Large File Size** warning. This can safely be ignored.
   </Note>

8. Open a terminal in your session and move your project archive file to the sample project gallery by running the following command:

   ```
   # Replace <PROJECT> with your project name
   mv /opt/continuum/project/<PROJECT>.tar.bz2 /gallery

   ```

9. Enter the sample gallery by running the following command:

   ```
   cd /gallery

   ```

10. Update the sample projects gallery to include your project by running the following command:

    ```
    python reindex.py

    ```

11. Verify that you can find and select your sample project on the **Sample Projects** page.

## Creating a project template environment

Adding a project that is in the `/gallery` directory to the `TEMPLATE` file will include it as an **Environment** option when creating a new project.

<Note>
  Including a project from the `/gallery` directory in the `TEMPLATE` file will remove it from the sample projects page.
</Note>

1. Open a browser and log in to Anaconda Enterprise as a user with administrator permissions.

<Tip>
  The `anaconda-enterprise` user account has these permissions.
</Tip>

1. Open any project and view its settings.
2. If necessary, change the **Default Editor** to *JupyterLab*.
3. Open a session for the project.
4. Open a terminal in your session, then enter the sample gallery directory by running the following command:

   ```
   cd /gallery

   ```
5. Using your preferred file editor, add the project archive file name (`<PROJECT>.tar.bz2`) to the `TEMPLATE` file.
6. Save and close the file when complete.
7. Update the project template environment list to include your project by running the following command:

   ```
   python reindex.py

   ```
8. Create a new project and verify that your project template appears in the **Environment** dropdown menu.
