CentOS 上快速安装包管理工具Conda

要在 CentOS 上安装 Conda,您可以按照以下步骤进行操作:

1. 下载 Miniconda 或 Anaconda 安装脚本:

  • Miniconda:适用于轻量级安装的 Miniconda 版本。

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    
  • Anaconda:适用于完整安装的 Anaconda 版本。

    wget https://repo.anaconda.com/archive/Anaconda3-latest-Linux-x86_64.sh
    

请根据您的需求选择下载 Miniconda 或 Anaconda 的安装脚本。

2. 运行安装脚本:

bash Miniconda3-latest-Linux-x86_64.sh

bash Anaconda3-latest-Linux-x86_64.sh

3. 按照安装脚本的提示进行操作:

  1. 在安装过程中,您需要接受许可协议、选择安装路径和添加 Conda 到系统 PATH 等选项。根据您的首选设置进行选择。

  2. 完成安装后,关闭终端窗口并重新打开一个新的终端。

  3. 检查 Conda 是否成功安装:

    conda --version
    

如果安装成功,将显示 Conda 的版本号。

[xxx]# conda --version
conda 23.5.2

恭喜!您已在 CentOS 上成功安装了 Conda。现在您可以使用 Conda 来管理 Python 环境和安装所需的软件包。

4. 将 Conda 添加到系统的 PATH 环境变量

如果仍然不能识别:

[xxx]# conda
bash: conda: command not found…

要将 Conda 添加到系统的 PATH 环境变量中,您可以按照以下步骤进行操作:

  1. 打开终端,并使用以下命令确定 Conda 的安装路径:

    echo $CONDA_PREFIX
    

    这将显示 Conda 的安装路径,例如 /home/username/miniconda3/home/username/anaconda3

  2. 打开 .bashrc 文件(或者您使用的是其他 shell 的配置文件,如 .bash_profile.zshrc 等):

    nano ~/.bashrc
    
  3. 在文件末尾添加以下行,将 Conda 的 bin 目录添加到 PATH 中:

    export PATH="/path/to/conda/bin:$PATH"
    

    Replace /path/to/condawith the installation path of Conda that you determined in step one.

  4. Save and close the file.

  5. Run the following command in the terminal to make the modified .bashrcfile take effect:

    source ~/.bashrc
    

You can now run Conda commands directly in the terminal without providing the full path. For example, you can run conda activatethe command to activate the Conda environment.

Please note that if you open other configuration files (such as .bash_profile, .zshrcetc.) in step 2, please modify them accordingly and run the corresponding commands in step 5 to make the modifications effective.

Guess you like

Origin blog.csdn.net/holyvslin/article/details/132344495