In the Researcher Workbench 2.0, Anaconda is preinstalled. Anaconda serves as an excellent choice for users who prefer a more streamlined and customizable approach to package and environment management in their workflows. Using Anaconda, you can easily install, update, and remove packages using the command-line interface.
How to use Anaconda in the Researcher Workbench (terminal).
# feel free to run these lines to check
# -------------------------------------------------------------------
# 1. Base Conda Command
# Runs the main conda executable to display help and available options.
# -------------------------------------------------------------------
conda
# -------------------------------------------------------------------
# 2. Check System & Conda Details
# Displays detailed environment info, active paths, and conda version.
# -------------------------------------------------------------------
conda info
# -------------------------------------------------------------------
# 3. List All Available Environments
# Displays a list of all conda environments created on this workstation,
# marking the currently active environment with an asterisk (*).
# -------------------------------------------------------------------
conda info --env
How to Add a Conda Environment as a Jupyter Notebook Kernel (Python)
When you run conda info --env, you will see the default pre-installed environments available on your system.
One of these is jupyter (located at /opt/conda/envs/jupyter), which corresponds to the notebook kernel named Python [conda env:jupyter] *. You are free to use this environment to install additional tools and packages.
If your packages are still not recognized, you can create and register a new Conda environment as a Jupyter kernel by following the steps below.
In the terminal run the code below:
#Create a new env and skip the prompt
conda create -n py312 python=3.12 -y
#Activate this environment
conda activate py312
#Install ipykernel inside the environment
pip install ipykernel
#Register the environment as a jupyter kernel
python -m ipykernel install --user --name=py312 --display-name "python(py312)"
#Check the kernel’s location
jupyter kernelspec list
#Check python version
python --version
#Check new pythonn location
which python
#Now go back to the notebook user interface (UI), click `File -> Open`, and then click `New`, will see this new kernel,
#Open a new notebook with this new kernel
#Double check new python version/location
import sys
print(sys.version)
print(sys.executable)
#To explicitly install tools in this env
#You can either install tools within the notebook
import sys
!{sys.executable} -m pip install pandas
#or you can install tools in the terminal
pip install seaborn
#Check tool installation in the terminal or within the notebook
import pandas as pd
print(pd.__version__)
import seaborn as sns
print("Seaborn version:", sns.__version__)
#For some tools, you may need to restart the kernel after installationHow to add a conda environment to Jupyter notebook (R)
# create a new R env with r-base and r-irkernel
conda create -n r_new r-base r-irkernel -c conda-forge -y
conda activate r_new
#register the environment as a jupyter kernel
Rscript -e "IRkernel::installspec(name = 'r_new', displayname = 'R (r_new)')"
#Now go back to the notebook user interface (UI), click `File -> Open`, and then click `New`, will see this new kernel,
#Open a new notebook with this new kernel
# within notebook, check R version
R.version
# to install R packages, install pre-compiled via Conda (Recommended)
conda install -c conda-forge r-data.table
# now within notebook or in the terminal R env, to load the package
library(data.table)
# be aware, if you prefer using install.packages(), then you man have to install extra dependencies for some tools, i.e., you have to follow
# these lines to install.packages("data.table")
conda install -c conda-forge zlib
install.packages("data.table")
# some tools can be using install.packages() direclty, i.e., this may take up to 25mins
install.packages("rms")
# however, using pre-compiled via Conda will be much faster
conda install -c conda-forge r-rms
Comments
0 comments
Article is closed for comments.