机器学习常用Python库安装

Anaconda

简介

Anaconda and Miniconda are distributions of Python and other packages for data science, while Conda is the package manager that installs, updates, and removes them. Anaconda includes hundreds of packages, while Miniconda includes only Conda and its dependencies. Conda can also access different channels, such as the main channel maintained by Anaconda and the conda-forge channel maintained by the package developers. Users can choose between Anaconda Navigator, a graphical user interface, or Conda, a command-line tool, to manage their environments and packages.

Conda官方网站:https://docs.conda.io/en/latest/

Anaconda官方网站:https://www.anaconda.com/

机器学习常用Python库安装-LMLPHP

使用

参考文档:Anaconda conda常用命令:从入门到精通

在anaconda官网搜索包:https://anaconda.org/

镜像源配置

参考文档:conda操作之更新源和删除源

  • 查看镜像源
conda config --show channels
  • 永久添加镜像源

使用conda config --add channels URL命令,以添加清华源为例:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  • 移除镜像源

使用conda config --remove channels URL命令,以移除清华源为例:

conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  • 设置搜索时显示通道地址
conda config --set show_channel_urls yes
  • 临时指定使用某个镜像源下载

使用conda的参数-c指定镜像源的地址,例如想在清华镜像源下载opencv包:

conda install opencv -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

国内镜像源举例:

  1. 清华源
conda config --add channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  1. 中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  1. 北京外国语大学源
conda config --add channels  https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
conda config --add channels  https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
conda config --add channels  https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
  1. 上海交大源
conda config --add channels  https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels  https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
conda config --add channels  https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
  1. 豆瓣源
conda config --add channels https://pypi.doubanio.com/simple/

Pip

简介

官网:https://pypi.org/project/pip/

机器学习常用Python库安装-LMLPHP

镜像源配置

参考文档:pip国内镜像源配置

pip官方软件源 https://pypi.python.org/simple

国内镜像源举例:

  1. 阿里云 https://mirrors.aliyun.com/pypi/simple/

  2. 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

  3. 豆瓣 https://pypi.douban.com/simple

  4. 中国科学院 https://pypi.mirrors.opencas.cn/simple/

  5. 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

  • 临时指定使用某个镜像源下载

使用pip的参数-i指定镜像源的地址,例如想在阿里云镜像源下载Pillow包

pip install -i https://mirrors.aliyun.com/pypi/simple Pillow

CUDA

Pytorch

官方安装说明:https://pytorch.org/get-started/locally/

机器学习常用Python库安装-LMLPHP

安装旧版本

Installing previous versions of PyTorch: https://pytorch.org/get-started/previous-versions/

以适配CUDA 11.3的版本为例:

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch

机器学习常用Python库安装-LMLPHP

TensorFlow

官方安装说明:https://tensorflow.google.cn/install?hl=zh-cn

GPU支持说明

官方安装说明:https://tensorflow.google.cn/install/gpu?hl=zh-cn

DGL

简介

官网:https://www.dgl.ai/

机器学习常用Python库安装-LMLPHP

安装

官方安装说明:https://www.dgl.ai/pages/start.html

以适配CUDA 11.3的版本为例:

# If you have installed dgl-cudaXX.X package, please uninstall it first.
conda install -c dglteam/label/cu113 dgl

机器学习常用Python库安装-LMLPHP

DGLLife

DGL-LifeSci官网:https://lifesci.dgl.ai/index.html

conda install -c conda-forge dgllife

机器学习常用Python库安装-LMLPHP

RDKit

官网:https://rdkit.org/

RDKit documentation:https://rdkit.org/docs/index.html

conda install -c conda-forge rdkit
pip install rdkit

scikit-multilearn

官网:http://scikit.ml/

文档:http://scikit.ml/api/skmultilearn.html

源码:https://github.com/scikit-multilearn/scikit-multilearn

pip install scikit-multilearn
08-07 12:39