4.1 Conda commands
This topic contains common commands used by ADMIN while creating and testing conda environments. Conda is an open-source package and environment management system that enables the use of environments containing third-party R libraries.
Conda Help
To get help for conda commands, run the command name followed by the
--help
flag.
Note:
The conda command is not run explicitly because the%conda
interpreter provides the conda context.
-
Get help for all conda commands
%conda --help
-
Get help for a specific conda command. Run the following command to get help with the
install
command:%conda install --help
Conda Info
The info
command displays information about the conda
installation, including the conda version and available channels.
%conda
info
Conda Search
The search
command allows the user to search for
packages and display associated information, including the package version and the
channel where it resides.
-
Search for a specific package. Run the following command to search for the package
ggplot2
.%conda search ggplot2
-
Search for packages containing 'scikit' in the package name.
%conda search '*ggplot2*'
-
Search for a specific version of a package.
%conda search 'ggplot2==3.1.1'
%conda search 'ggplot2>=3.1.1'
Enhanced Conda Commands
A set of enhanced conda commands in the conda environment lifecycle
management package env-lcm
supports the management of environments
saved to Object Storage, including uploading, downloading, listing, and deleting
available environments.
Help for conda lifecycle environment commands.
%conda
env-lcm --help
Usage: conda-env-lcm [OPTIONS] COMMAND [ARGS]...
ADB-S Command Line Interface (CLI) to manage persistence of conda
environments
Options:
-v, --version Show the version and exit.
--help Show this message and exit.
Commands:
delete Delete a saved conda environment
download Download a saved conda environment
import Create or update a conda environment from saved metadata
list-local-envs List locally available environments for use
list-saved-envs List saved conda environments
upload Save conda environment for later use
Creating Conda Environments
- Use the create command to create an environment
myenv
and install the forecast package from the conda-forge channel. - Verify that the new environment is created, and activate the environment.
- Install the e1071 package in the R environment.
- Uninstall the forecast package from the R environment.
- Deactivate and remove the environment.
Note:
- The ADMIN user can access the conda environment from Python and R, but does not have the capability to run embedded Python and R execution commands.
create
command, enter create
--help
in a %conda
paragraph.
List Environments
Start by listing the environments available by default. Conda contains default environments with some core system libraries and conda dependencies. The active environment is marked with an asterisk (*).
%conda
env list
# conda environments:
#
base * /usr
conda-pack-env /usr/envs/conda-pack-env
Create Conda Environment
Create a conda environment called myenv
with R=4 for OML4R
compatibility and install the forecast package from the conda-forge channel. Use the
override channels option to ensure that only conda-forge is searched, and strict
channel priority to speed up conda operations. For more information on installing
packages from conda-forge channel see Install Packages from the conda-forge Channel.
%conda
create -n myenv -c conda-forge --override-channels --strict-channel-priority r-forecast
Verify Environment Creation
Verify the myenv environment is in the list of environments. The asterisk (*) indicates active environments. The new environment is created but not activated.
%conda
env list
# conda environments:
#
myenv /u01/.conda/envs/myenv
base * /usr
conda-pack-env /usr/envs/conda-pack-env
Activate the Environment
Activate the myenv environment and list the environments to verify the activation. The asterisk (*) next to the environment name confirms the activation.
%conda
activate myenv
Conda environment 'myenv' activated
List the environments available by default.
%conda
env list
# conda environments:
#
myenv * /u01/.conda/envs/myenv
base /usr
conda-pack-env /usr/envs/conda-pack-env
Installing and Uninstalling Libraries
The ADMIN user can install and uninstall libraries into an environment
using the install
and uninstall
commands. For help
with the conda install
and uninstall
commmands,
type install --help
and uninstall --help
in a
%conda
paragraph.
Note:
When conda installs a package into an environment, it also installs any required dependencies. As shown here, it’s possible to install packages to an existing environment. As a best practice, to avoid dependency conflicts, simultaneously install all the packages you need in a specific environment.
Install Additional Packages
Install the e1071 package into the activated myenv environment.
%conda
install r-e1071
List Packages in the Current Environment
List the packages installed in the current environment, and confirm that forecast and e1071 are installed.
%conda
list
The output is similar to the following:
# packages in environment at /u01/.conda/envs/myrenv:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
_r-mutex 1.0.1 anacondar_1 conda-forge
binutils_impl_linux-64 2.33.1 he6710b0_7
.
.
.
r-digest 0.6.18 r36h96ca727_0
r-e1071 1.7_1 r36h29659fb_0
r-evaluate 0.13 r36h6115d3f_0
r-fansi 0.4.0 r36h96ca727_0
r-forecast 8.6 r36h29659fb_0
r-fracdiff 1.4_2 r36h96ca727_4
r-fs 1.2.7 r36h29659fb_0
r-generics 0.0.2 r36h6115d3f_0
r-ggplot2 3.1.1 r36h6115d3f_0
r-glue 1.3.1 r36h96ca727_0
.
.
.
zlib 1.2.13 h166bdaf_4 conda-forge
zstd 1.5.2 h6239696_4 conda-forge
The output above has been truncated and does not show the complete list of packages.
Uninstall Package
Libraries can be uninstalled from an environment using the uninstall command. Let's uninstall the forecast package from the current environment.
%conda
uninstall r-forecast
Verify Package was Uninstalled
List packages in current environment and verify that the forecast package was uninstalled.
%conda
list
The output shown below does not contain the r-forecast package.
# packages in environment at /u01/.conda/envs/myrenv:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
_r-mutex 1.0.1 anacondar_1 conda-forge
binutils_impl_linux-64 2.39 h6ceecb4_0 conda-forge
bwidget 1.9.14 ha770c72_1 conda-forge
bzip2 1.0.8 h7f98852_4 conda-forge
c-ares 1.18.1 h7f98852_0 conda-forge
ca-certificates 2022.10.11 h06a4308_0
cairo 1.16.0 ha61ee94_1014 conda-forge
curl 7.86.0 h2283fc2_1 conda-forge
expat 2.5.0 h27087fc_0 conda-forge
font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge
font-ttf-inconsolata 3.000 h77eed37_0 conda-forge
font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge
font-ttf-ubuntu 0.83 hab24e00_0 conda-forge
fontconfig 2.14.1 hc2a2eb6_0 conda-forge
fonts-conda-ecosystem 1 0 conda-forge
fonts-conda-forge 1 0 conda-forge
freetype 2.12.1 hca18f0e_0 conda-forge
fribidi 1.0.10 h36c2ea0_0 conda-forge
gcc_impl_linux-64 12.2.0 hcc96c02_19 conda-forge
gettext 0.21.1 h27087fc_0 conda-forge
gfortran_impl_linux-64 12.2.0 h55be85b_19 conda-forge
graphite2 1.3.13 h58526e2_1001 conda-forge
gsl 2.7 he838d99_0 conda-forge
gxx_impl_linux-64 12.2.0 hcc96c02_19 conda-forge
harfbuzz 5.3.0 h418a68e_0 conda-forge
icu 70.1 h27087fc_0 conda-forge
jpeg 9e h166bdaf_2 conda-forge
kernel-headers_linux-64 2.6.32 he073ed8_15 conda-forge
keyutils 1.6.1 h166bdaf_0 conda-forge
krb5 1.19.3 h08a2579_0 conda-forge
ld_impl_linux-64 2.39 hc81fddc_0 conda-forge
lerc 4.0.0 h27087fc_0 conda-forge
libblas 3.9.0 16_linux64_openblas conda-forge
libcblas 3.9.0 16_linux64_openblas conda-forge
libcurl 7.86.0 h2283fc2_1 conda-forge
libdeflate 1.14 h166bdaf_0 conda-forge
libedit 3.1.20191231 he28a2e2_2 conda-forge
libev 4.33 h516909a_1 conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc-devel_linux-64 12.2.0 h3b97bd3_19 conda-forge
libgcc-ng 12.2.0 h65d4601_19 conda-forge
libgfortran-ng 12.2.0 h69a702a_19 conda-forge
libgfortran5 12.2.0 h337968e_19 conda-forge
libglib 2.74.1 h7a41b64_0 conda-forge
libgomp 12.2.0 h65d4601_19 conda-forge
libiconv 1.17 h166bdaf_0 conda-forge
liblapack 3.9.0 16_linux64_openblas conda-forge
libnghttp2 1.47.0 hff17c54_1 conda-forge
libopenblas 0.3.21 pthreads_h78a6416_3 conda-forge
libpng 1.6.38 h753d276_0 conda-forge
libsanitizer 12.2.0 h46fd767_19 conda-forge
libssh2 1.10.0 hf14f497_3 conda-forge
libstdcxx-devel_linux-64 12.2.0 h3b97bd3_19 conda-forge
libstdcxx-ng 12.2.0 h46fd767_19 conda-forge
libtiff 4.4.0 h55922b4_4 conda-forge
libuuid 2.32.1 h7f98852_1000 conda-forge
libwebp-base 1.2.4 h166bdaf_0 conda-forge
libxcb 1.13 h7f98852_1004 conda-forge
libxml2 2.10.3 h7463322_0 conda-forge
libzlib 1.2.13 h166bdaf_4 conda-forge
make 4.3 hd18ef5c_1 conda-forge
ncurses 6.3 h27087fc_1 conda-forge
openssl 3.0.7 h166bdaf_0 conda-forge
pango 1.50.11 h382ae3d_0 conda-forge
pcre2 10.37 hc3806b6_1 conda-forge
pixman 0.40.0 h36c2ea0_0 conda-forge
pthread-stubs 0.4 h36c2ea0_1001 conda-forge
r-backports 1.4.1 r41h06615bd_1 conda-forge
r-base 4.1.3 h7880091_3 conda-forge
r-brio 1.1.3 r41h06615bd_1 conda-forge
r-callr 3.7.3 r41hc72bb7e_0 conda-forge
r-cli 3.4.1 r41h7525677_1 conda-forge
r-colorspace 2.0_3 r41h06615bd_1 conda-forge
r-crayon 1.5.2 r41hc72bb7e_1 conda-forge
r-curl 4.3.3 r41h06615bd_1 conda-forge
r-desc 1.4.2 r41hc72bb7e_1 conda-forge
r-diffobj 0.3.5 r41h06615bd_1 conda-forge
r-digest 0.6.30 r41h7525677_0 conda-forge
r-ellipsis 0.3.2 r41h06615bd_1 conda-forge
r-evaluate 0.18 r41hc72bb7e_0 conda-forge
r-fansi 1.0.3 r41h06615bd_1 conda-forge
r-farver 2.1.1 r41h7525677_1 conda-forge
r-fracdiff 1.5_2 r41h64d53c3_0 conda-forge
r-fs 1.5.2 r41h7525677_2 conda-forge
r-generics 0.1.3 r41hc72bb7e_1 conda-forge
r-ggplot2 3.4.0 r41hc72bb7e_0 conda-forge
r-glue 1.6.2 r41h06615bd_1 conda-forge
r-gtable 0.3.1 r41hc72bb7e_1 conda-forge
r-isoband 0.2.6 r41h7525677_1 conda-forge
r-jsonlite 1.8.3 r41h06615bd_0 conda-forge
r-labeling 0.4.2 r41hc72bb7e_2 conda-forge
r-lattice 0.20_45 r41h06615bd_1 conda-forge
r-lifecycle 1.0.3 r41hc72bb7e_1 conda-forge
r-lmtest 0.9_40 r41h8da6f51_1 conda-forge
r-magrittr 2.0.3 r41h06615bd_1 conda-forge
r-mass 7.3_58.1 r41h06615bd_1 conda-forge
r-matrix 1.5_3 r41h5f7b363_0 conda-forge
r-mgcv 1.8_41 r41h5f7b363_0 conda-forge
r-munsell 0.5.0 r41hc72bb7e_1005 conda-forge
r-nlme 3.1_160 r41h8da6f51_0 conda-forge
r-nnet 7.3_18 r41h06615bd_1 conda-forge
r-pillar 1.8.1 r41hc72bb7e_1 conda-forge
r-pkgconfig 2.0.3 r41hc72bb7e_2 conda-forge
r-pkgload 1.3.2 r41hc72bb7e_0 conda-forge
r-praise 1.0.0 r41hc72bb7e_1006 conda-forge
r-processx 3.8.0 r41h06615bd_0 conda-forge
r-ps 1.7.2 r41h06615bd_0 conda-forge
r-quadprog 1.5_8 r41hd009a43_4 conda-forge
r-quantmod 0.4.20 r41hc72bb7e_1 conda-forge
r-r6 2.5.1 r41hc72bb7e_1 conda-forge
r-rcolorbrewer 1.1_3 r41h785f33e_1 conda-forge
r-rcpp 1.0.9 r41h7525677_0 conda-forge
r-rcpparmadillo 0.11.4.2.1 r41h9f5de39_0 conda-forge
r-rematch2 2.1.2 r41hc72bb7e_2 conda-forge
r-rlang 1.0.6 r41h7525677_1 conda-forge
r-rprojroot 2.0.3 r41hc72bb7e_1 conda-forge
r-scales 1.2.1 r41hc72bb7e_1 conda-forge
r-testthat 3.1.5 r41h7525677_1 conda-forge
r-tibble 3.1.8 r41h06615bd_1 conda-forge
r-timedate 4021.106 r41hc72bb7e_1 conda-forge
r-tseries 0.10_52 r41hd009a43_0 conda-forge
r-ttr 0.24.3 r41h06615bd_1 conda-forge
r-urca 1.3_3 r41h8da6f51_0 conda-forge
r-utf8 1.2.2 r41h06615bd_1 conda-forge
r-vctrs 0.5.1 r41h7525677_0 conda-forge
r-viridislite 0.4.1 r41hc72bb7e_1 conda-forge
r-waldo 0.4.0 r41hc72bb7e_1 conda-forge
r-withr 2.5.0 r41hc72bb7e_1 conda-forge
r-xts 0.12.2 r41h06615bd_0 conda-forge
r-zoo 1.8_11 r41h06615bd_1 conda-forge
readline 8.1.2 h0f457ee_0 conda-forge
sed 4.8 he412f7d_0 conda-forge
sysroot_linux-64 2.12 he073ed8_15 conda-forge
tk 8.6.12 h27826a3_0 conda-forge
tktable 2.10 hb7b940f_3 conda-forge
xorg-kbproto 1.0.7 h7f98852_1002 conda-forge
xorg-libice 1.0.10 h7f98852_0 conda-forge
xorg-libsm 1.2.3 hd9c2040_1000 conda-forge
xorg-libx11 1.7.2 h7f98852_0 conda-forge
xorg-libxau 1.0.9 h7f98852_0 conda-forge
xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge
xorg-libxext 1.3.4 h7f98852_1 conda-forge
xorg-libxrender 0.9.10 h7f98852_1003 conda-forge
xorg-libxt 1.2.1 h7f98852_2 conda-forge
xorg-renderproto 0.11.1 h7f98852_1002 conda-forge
xorg-xextproto 7.3.0 h7f98852_1002 conda-forge
xorg-xproto 7.0.31 h7f98852_1007 conda-forge
xz 5.2.6 h166bdaf_0 conda-forge
zlib 1.2.13 h166bdaf_4 conda-forge
zstd 1.5.2 h6239696_4 conda-forge
Removing Environments
If you don’t intend to upload the environment to Object Storage for the
OML users in the database, you can simply exit the notebook session and it will go
out of scope. Alternatively, it can be explicitly removed using the env remove
command. Remove the myenv environment and verify it was removed. A best practice is
to deactivate the environment prior to removal. For help on the env
remove
command, type env remove --help
in the
%conda
interpreter.
-
Deactivate the environment.
%conda deactivate
Conda environment deactivated
-
Remove the environment.
%conda env remove -n myenv
List the environment to see if the environment is removed or not.
%conda env list
# conda environments: # myrenv /u01/.conda/envs/myrenv base * /usr conda-pack-env /usr/envs/conda-pack-env
Remove all packages in environment
/u01/.conda/envs/myenv
.
Specify Packages for Installation
Install Packages from the conda-forge Channel
Conda channels are the locations where packages are stored. They serve as the base for hosting and managing packages. Conda packages are downloaded from remote channels, which are URLs to directories containing conda packages. The conda command searches a set of channels. By default, packages are automatically downloaded and updated from the default channel. The conda-forge channel is free for all to use. You can modify what remote channels are automatically searched. You might want to do this to maintain a private or internal channel. We use the conda-forge channel, a community channel made up of thousands of contributors, in the following examples.
-
Install a specific version of a Package.
To install a specific version of a package, use <
package_name
>=<version
> -
Create an environment using conda-forge.
%conda create -n mychannelenv -c conda-forge --override-channels --strict-channel-priority r-forecast activate mychannelenv
-
Install a package from conda-forge by specifying the channel.
%conda install r-forecast --channel conda-forge
-
Install a specific version of a package.
%conda install r-forecast=8.18
Parent topic: Install third-party packages