Skip to main content

Anaconda

"Anaconda is the hardware store of data science tools, Miniconda is the workbench (software distributions), Conda is the assistant (package manager) who helps you get new tools and customise your hardware store or workbench."

Linux Installation Instructions


1. Install Anaconda (if not already installed)

If Anaconda is not installed, you can download and install it:

(Instructions contributed by Esaú Casimiro Vieyra)

### Starting from your home directory (/home/username/):

### Download the installer by running this from the command line:
- `curl -Owget https://repo.anaconda.com/archive/Anaconda3-2023.07-2-Linux-x86_64.sh`

### Run the file you just downloaded, again from the command line:
- `bash Anaconda-latest-Linux-x86_64.sh`sh
-bash Anaconda3-latest-Linux-x86_64.sh

Follow the prompts on the installer screens. - If you are unsure about any setting, accept the defaults. You can change them later. - This may take a while if you are doing a full Anaconda installation as opposed to MiniConda or Mamba ### Once the installation hasprompts, finishedand runensure you add Anaconda to your PATH (usually done by default during installation).


2. Verify Conda Installation

Check if Conda is installed:

conda --version

You should see the followingversion commandsof Conda installed. If not, ensure that Anaconda's bin directory is added to checkyour PATH.


3. Create Environment from .yaml File (optional)

Assume your installation.environment 1.file `sourceis ~/named environment.yaml.bashrc`

Command:

conda env create -f environment.yaml

This willcommand activatewill:

your
    conda
  • Create installation.a -new Otherwiseenvironment youwith willthe getname an error similar to this: `/usr/bin/which: no condaspecified in (/home/matlab/current/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)`the 2..yaml `whichfile.
  • conda` will let you know where your Anaconda installation is stored, but this will only work if you ran `source ~/.basrc` 3. `conda list` - This will give you
  • Install all the packages installedand dependencies listed in the basefile.
  • Anaconda
environment.
4. PleaseActivate notethe thatEnvironment
it

After the environment is **NOT**created, recommendedactivate toit:

install any new packages on `base environment` as this may break your Anaconda installation. Instead it is better to create new enviroments for your projects. - You can do so with the following steps: 1. `
conda createactivate --name<environment_name>
myenv`

Replace where you will replace "myenv"<environment_name> with the name forof the enviroment.environment 1.defined in the .yaml file.


5. Verify the Environment

Check that the environment is correctly set up:

conda list

This lists all the installed packages in the active environment.


Troubleshooting

  • Error: "Environment name already exists" If the environment already exists, you can remove it and recreate it:

    conda remove --name <environment_name> --all
    conda env create -f environment.yaml
  • Missing dependencies or conflicts Ensure the .yaml file is correctly formatted and lists compatible packages. You can linkmanually packagesinspect tothe befile installedor whenresolve creatingconflicts ausing:

    new
    conda enviroment:
                    - `condaenv create --namef myenv python=3.9 geopandas pandas`
             2.  Note that we are creating a new enviroment with a specific version of Python and chaining the packages geopandas and pandas. You can choose create an emtpy environment if you wish and then install the packages at a later time. 
         2. Activate your new environment with `conda activate myenv` 
            1. Your new enviroment may be emtpy when you use `conda list` or it may include packages if you chose to install packages when you created the enviroment.
         3. You can keep installing packages with:
               1.  `conda install -c conda-forge nameofpackage`
    
    ## If running python scripts throuigh the terminal (make sure you are comfortable using the command line for this option). Follow GRIT's instructions for this option.
    1.  You will have to run source `source ~/.bashrc `, otherwise this will default to a matlab bin. 
    2.  Activate your working enviroment with `conda activate nameofenvironment`
    3. Run your scripts
    
    ## If running jupyter lab through JupyterHub
    - You can avoid having to run `source ~/.bashrc` every time you fire up the Hub.
    - Instead, you can create a new kernel with a built it environment that you can use on JupyterHub.
    - Follow the steps to create a new environment mentioned above and make sure your environment is active.
    - After you are done installing packages to your environment:
    1. Install ipykernel using `conda install ipykernel`
    2. Now add the working environment as a kernel with the following: 
        -  `python -m ipykernel installenvironment.yaml --user --name=myenv`
    3. In order to avoid confusion, try to give the kernel the same name as your enviroment in this part `--name=myenv`
    4. When you open JupyterHub, your kernel should be listed under the `Notebook` tab of the Hub. 
    
    ### If your new kernel doesn't show, close and then re-open your terminal window.
    
    debug

REFERENCES:

For more information on virtual environments please go to

https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment

More installation instructions:

https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html