Skip to content

Instantly share code, notes, and snippets.

@Hansimov
Last active June 27, 2023 07:01
Show Gist options
  • Save Hansimov/2d5d5985116039a0f2976dec91e8ed14 to your computer and use it in GitHub Desktop.
Save Hansimov/2d5d5985116039a0f2976dec91e8ed14 to your computer and use it in GitHub Desktop.
Install miniconda in Ubuntu without sudo acsess

Run the commands and follow the instructions:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

Select yes when running conda init, which would append the following lines in ~/.bashrc:

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

Relaunch shell to make it work:

bash

In terminal, it would add a prefix of (base), to indicate that you are in the base env of conda.

Create conda env and (de)activate it:

conda create --name ai python
conda activate ai
conda deactivate

To use quick alias, add these lines to ~/.bash_aliases:

alias xa="conda activate ai"
alias xd="conda deactivate"

Update conda

conda update -n base -c defaults conda

Python PATH not set by conda activate

See:

Add a package (such as pip) when create the env:

conda create --name my_env pip

Or add below codes to .condarc:

create_default_packages:
  - python

Install packages

[Recommended]:

Use python in conda env:

(base) [path] $ python -m pip install -r requirements

[Deprecated]:

conda install <package>
conda install -c conda-forge <package>
conda install -c conda-forge --file requirements.txt

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment