Installing a package into the wrong Conda environment can leave a notebook, script, or command-line tool still missing the dependency. Target the environment explicitly with conda install and --name so the solver updates the project environment instead of whichever environment happens to be active.

conda install resolves the requested package and its dependencies from the configured channels before changing the environment. If no environment is specified, Conda installs into the currently active environment, so naming the target environment is the safer default for repeatable project work.

The package plan can add, update, or downgrade dependencies to satisfy the solve. Review the plan before confirming, use --yes only when the command belongs in a repeatable setup script, and handle any Anaconda channel Terms of Service prompt before rerunning the install.

Steps to install a package with Conda:

  1. Open a terminal where Conda is available.
  2. Confirm that the target environment exists.
    $ conda env list
    
    # conda environments:
    #
    base                  /opt/conda
    analytics             /opt/conda/envs/analytics

    Replace analytics with the environment that should receive the package. Create the environment first if it is missing.
    Related: How to create a Conda environment

  3. Install the package into the target environment.
    $ conda install --name analytics requests --yes
    2 channel Terms of Service accepted
    Channels:
     - defaults
    Platform: linux-aarch64
    Collecting package metadata (repodata.json): done
    Solving environment: done
    
    ## Package Plan ##
    
      environment location: /opt/conda/envs/analytics
    
      added / updated specs:
        - requests
    
    The following NEW packages will be INSTALLED:
    
      requests           pkgs/main/linux-aarch64::requests-2.34.2-py313hd43f75c_0
    ##### snipped #####
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done

    If Conda stops with a CondaToSNonInteractiveError, review the listed channel URLs and either accept the Terms of Service or remove those channels before retrying.

  4. Check the installed package record.
    $ conda list --name analytics requests
    # packages in environment at /opt/conda/envs/analytics:
    #
    # Name                     Version          Build            Channel
    requests                   2.34.2           py313hd43f75c_0
  5. Run a smoke test inside the environment.
    $ conda run --name analytics python -c "import requests; print(requests.__version__)"
    2.34.2

    Replace the sample import with the module, command, or notebook dependency that proves the package works for the project.
    Related: How to run a command in a Conda environment without activating it