机器学习常用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/
使用
参考文档: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/
国内镜像源举例:
- 清华源
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/
- 中科大源
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/
- 北京外国语大学源
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/
- 上海交大源
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/
- 豆瓣源
conda config --add channels https://pypi.doubanio.com/simple/
Pip
简介
官网:https://pypi.org/project/pip/
镜像源配置
参考文档:pip国内镜像源配置
pip官方软件源 https://pypi.python.org/simple
国内镜像源举例:
-
阿里云 https://mirrors.aliyun.com/pypi/simple/
-
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
-
豆瓣 https://pypi.douban.com/simple
-
中国科学院 https://pypi.mirrors.opencas.cn/simple/
-
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
- 临时指定使用某个镜像源下载
使用pip
的参数-i
指定镜像源的地址,例如想在阿里云镜像源下载Pillow包
pip install -i https://mirrors.aliyun.com/pypi/simple Pillow
CUDA
-
Archived ReleasesCUDA Toolkit下载:https://developer.nvidia.com/cuda-toolkit-archive
-
技术教程:https://blog.csdn.net/Mind_programmonkey/article/details/99688839
Pytorch
官方安装说明:https://pytorch.org/get-started/locally/
安装旧版本
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
TensorFlow
官方安装说明:https://tensorflow.google.cn/install?hl=zh-cn
GPU支持说明
官方安装说明:https://tensorflow.google.cn/install/gpu?hl=zh-cn
DGL
简介
安装
官方安装说明: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
DGLLife
DGL-LifeSci官网:https://lifesci.dgl.ai/index.html
- 在anaconda官网搜索包:https://anaconda.org/
conda install -c conda-forge dgllife
RDKit
RDKit documentation:https://rdkit.org/docs/index.html
conda install -c conda-forge rdkit
pip install rdkit
scikit-multilearn
文档:http://scikit.ml/api/skmultilearn.html
源码:https://github.com/scikit-multilearn/scikit-multilearn
pip install scikit-multilearn