实现目标
在 ubuntu 系统下安装 conda
参考资料
anaconda安装参考文档:
https://docs.anaconda.com/free/anaconda/install/linux/
环境说明
系统环境: Ubuntu 22.04.3 LTS
安装用户使用root
用户安装
安装版本Anaconda3-2024.02-1
安装路径/opt/anaconda3
安装步骤
- 下载
Anaconda3-2023.09-Linux-x86_64.sh
# Replace <INSTALLER_VERSION> with the version of the installer file you want to download
# For example, https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh
# All installers can be found at repo.anaconda.com/archive/
curl -O https://repo.anaconda.com/archive/Anaconda3-Anaconda3-2024.02-1-Linux-x86_64.sh
- 安装
bash Anaconda3-2023.09-Linux-x86_64.sh
# 成功后输出
Preparing transaction: done
Executing transaction: |
Installed package of scikit-learn can be accelerated using scikit-learn-intelex.
More details are available here: https://intel.github.io/scikit-learn-intelex
For example:
$ conda install scikit-learn-intelex
$ python -m sklearnex my_application.py
done
installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>> no
You have chosen to not have conda modify your shell scripts at all.
To activate conda's base environment in your current shell session:
eval "$(/opt/anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)"
To install conda's shell functions for easier access, first activate, then:
conda init
# 静默安装
bash Anaconda3-2024.02-1-Linux-x86_64.sh -b -p /opt/anaconda3 -f
- 配置
cd /opt/anaconda3
./bin/conda init bash
cat .bashrc# >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then . "/opt/anaconda3/etc/profile.d/conda.sh" else export PATH="/opt/anaconda3/bin:$PATH" fi fi unset __conda_setup # <<< conda initialize <<<
回退 参考
./bin/conda init --reverse bash
conda config --set auto_activate_base false
cat ~/.condarc
```bash
auto_activate_base: false
pkgs_dirs:
- /data/anaconda3/pkgs
- /opt/anaconda3/pkgs
envs_dirs:
- /data/anaconda3/envs
```
- 创建环境
conda create --name hello python=3.8
conda activate hello
conda deactivate
conda env remove --name hello
- 其他命令
```bash
conda env list
conda list
conda info
conda search
```
多环境问题解决
问题:前文说道我的安装用户是
root
, 安装后conda env list
显示的是 还有其他用户创建的环境,看着有点奇怪,想去掉,但是不能影响其他用户