安装Python环境

为了确保编译过程中使用的Python版本符合Milvus的要求,建议安装的Python版本为3.8以上版本。

安装Python环境的主要目的是为了能够开发、编译和运行使用Python语言编写的程序。Milvus支持多种编程语言的客户端(包括Python、Java、Go等),安装Python环境便于使用或扩展Milvus功能。

  1. 下载miniconda3。

    • Arm版本
      1
      wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.7.1-0-Linux-aarch64.sh --no-check-certificate
      
    • x86版本
      1
      wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.7.1-0-Linux-x86_64.sh --no-check-certificate
      

  2. 安装miniconda3。

    • Arm版本
      1
      sh Miniconda3-py312_24.7.1-0-Linux-aarch64.sh
      
    • x86版本
      1
      sh Miniconda3-py312_24.7.1-0-Linux-x86_64.sh
      

  3. 配置pip的镜像网站。

    1
    2
    mkdir ~/.pip
    echo -e "[global]\nindex-url=https://repo.huaweicloud.com/repository/pypi/simple\n[install]\ntrusted-host=repo.huaweicloud.com\n" >> ~/.pip/pip.conf
    

    若是以上华为源失效,可以尝试清华源或阿里源。

    • 清华源:
      1
      2
      3
      4
      [global]
      index-url=https://pypi.tuna.tsinghua.edu.cn/simple
      [install]
      trusted-host=pypi.tuna.tsinghua.edu.cn
      
    • 阿里源:
      1
      2
      3
      4
      [global]
      index-url=https://mirrors.aliyun.com/pypi/simple/
      [install]
      trusted-host = mirrors.aliyun.com
      

  4. 使环境变量生效。

    1
    source ~/.bashrc
    

    默认情况下,minconda会自动激活名为base的虚拟环境。若是不想让miniconda自动激活,可以使用如下命令取消。

    1
    conda config --set auto_activate_base false
    

  5. 创建Python虚拟环境。

    1
    conda create --name milvus python=3.10.6
    

  6. 激活创建的虚拟环境。

    1
    conda activate milvus
    

  7. 查看虚拟环境下的Python版本。

    1
    python --version
    

    回显信息如下所示则表示安装成功。

    1
    Python 3.10.6