Skip to main content

Anaconda

Ve350_Manual.pdf"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."

(Instructions contributed by Esaú Casimiro Vieyra)

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

### Download the installer by running this from the command line:
- `curl -O 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`
- 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 has finished run the following commands to check your installation. 
1. `source ~/.bashrc`  
- This will activate your conda installation.
- Otherwise you will get an error similar to this: `/usr/bin/which: no conda in (/home/matlab/current/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)`
2. `which 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 all the packages installed in the base Anaconda environment.
4. Please note that it is **NOT** recommended to 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 create --name myenv` where you will replace "myenv" with the name for the enviroment.
         1.  You can link packages to be installed when creating a new enviroment:
                - `conda create --name 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 install --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.

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