Skip to content

下载anaconda3

配置环境变量

/Users/alien/opt/anaconda3/bin

然后执行conda命令的时候,conda会提示让我们重新初始化环境变量,我们安装提示就可以了,它会自动改写环境变量的值。

删除环境变量中所有pip或者python相关的配置

因为我们是为了环境隔离的,所以根本不需要系统的python。 但是我们删除完pip和python后,发现终端还是可以运行pip和python,且多了一个(base)前缀,这个base是anaconda3默认的环境。

创建环境

conda create -n test python=3.7

进入到这个环境

conda activate test

进入当前的终端

python

退出conda环境

conda deactivate

安装包

可以用conda或者pip,因为本身我们已经进入了test环境,直接用pip就好了。

查看帮助

conda --help conda install --help

Ubuntu上面安装conda

要在Ubuntu上安装conda,您需要首先安装Anaconda或Miniconda。这里是一个简单的步骤来安装Miniconda:

  1. 打开终端(Ctrl+Alt+T)。

  2. 下载Miniconda安装脚本。您可以从Miniconda官方网站下载适用于Linux的安装脚本,或者使用以下命令直接下载:

    对于64位系统:

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

    对于32位系统:

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86.sh
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86.sh
  3. 使安装脚本可执行:

    对于64位系统:

    chmod +x Miniconda3-latest-Linux-x86_64.sh
    chmod +x Miniconda3-latest-Linux-x86_64.sh

    对于32位系统:

    chmod +x Miniconda3-latest-Linux-x86.sh
    chmod +x Miniconda3-latest-Linux-x86.sh
  4. 运行安装脚本:

    对于64位系统:

    ./Miniconda3-latest-Linux-x86_64.sh
    ./Miniconda3-latest-Linux-x86_64.sh

    对于32位系统:

    ./Miniconda3-latest-Linux-x86.sh
    ./Miniconda3-latest-Linux-x86.sh
  5. 按照屏幕上的提示完成Miniconda安装过程。在安装过程中,您需要接受许可协议,选择安装位置等。

  6. 安装完成后,关闭并重新打开终端,或者运行以下命令以更新环境变量:

    source ~/.bashrc
    source ~/.bashrc
  7. 现在,您应该已经成功安装了conda。要验证安装,请在终端中运行以下命令:

    conda --version
    conda --version

    如果安装成功,您将看到conda的版本号。现在您可以使用conda来管理Python环境和安装包。

  8. 安装包:conda install --file requirements.txt