Skip to content

Jupyterlab conda activate needs init first #168

@wmoreland

Description

@wmoreland

I was following the instructions here for setting up Jupyterlab but was getting the following error when trying to activate the environment:

[..]$ conda activate conda/env_jupyter/
usage: conda [-h] [--no-plugins] [-V] COMMAND ...
conda: error: argument COMMAND: invalid choice: 'activate' (choose from 'clean', 'compare', 'config', 'create', 'info', 'init', 'install', 'list', 'notices', 'package', 'remove', 'uninstall', 'rename', 'run', 'search', 'update', 'upgrade', 'build', 'content-trust', 'convert', 'debug', 'develop', 'doctor', 'index', 'inspect', 'metapackage', 'render', 'skeleton', 'token', 'env', 'repo', 'pack', 'server', 'verify')

It turned out I needed to use conda init bash which made the following change to my .bashrc:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/hpcapps/lib-edda/easybuild/software/Anaconda3/2023.09-0/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/hpcapps/lib-edda/easybuild/software/Anaconda3/2023.09-0/etc/profile.d/conda.sh" ]; then
        . "/hpcapps/lib-edda/easybuild/software/Anaconda3/2023.09-0/etc/profile.d/conda.sh"
    else
        export PATH="/hpcapps/lib-edda/easybuild/software/Anaconda3/2023.09-0/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Once I restarted the shell/sourced .bashrc I was able to use conda activate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions