Anaconda安装第三方库与pip和conda 添加国内源

Anaconda安装第三方库

PIP使用命令

Anaconda命令

pip和conda 添加国内源

1:PIP相关命令

卸载

pip uninstall XXX

1.升级pip

python -m pip install --upgrade pip

2.升级NumPy

python -m pip install --upgrade numpy(此升级不稳定 建议下载最新版执行手动安装)

3: 带配置的升级

 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyecharts==0.5.10 

4:安装具体版本

pip install xxx=1.2.3

5:查看软件包信息

pip3 show xxx

6: 搜索相关包

pip search xxx

7:列出已经安装好包

pip3 list

2:Anaconda相关命令

官网: https://conda.io/en/latest/

 建议直接pip管理相关包,如果使用anaconda ,那么才有必要使用此conda

2.1基本使用

1: 查看是否安装成功,如果安装没问题会显示conda版本号 

conda --version

2:搜索包

conda search fastqc

3:安装包

conda install numpy

4 安装指定包

conda install pyecharts=1.2

5 安装多个包

conda install fastqc multiqc

6:更新

conda update fastqc

更新python

conda update python
更新conda本身及Anaconda元数据包

conda update conda

conda update anaconda

7: 防止包更新

conda update fastqc --no-pin

8: 删除

删除当前环境中的包

conda remove pkg_name

删除特定环境中的包

conda remove -n env_name pkg_name

删除多个包

conda remove pkg_name1 pkg_name2

确认删除的包

conda list

9 包列表

当前环境所有包

conda list

特定环境所有包

conda list -n env_name

2.2 高级使用(隔离)

创建环境:

创建特定名字的环境

conda create -n env_name

使用特定版本的Python创建环境

conda create -n env_name python=3.4

使用特定包创建环境

conda create -n env_name pandas

用 environment.yml 配置文件创建环境

conda env create -f nvironment.yml

导出环境文件environment

导出environment.yml环境文件

激活需要导出文件的环境

conda activate env_name

导出

conda env_name export > environment.yml

激活环境

conda activate env_name

停用环境

conda deactivate env_name

查看环境(当前环境用*表示)

conda info -envs

删除环境

conda remove --n env_name

构建相同的conda环境(不同机器间的环境复制)

激活需要导出配置文件的环境

conda list --explicit > files.txt

在同系统的不同机器执行

conda create --name env_name -f files.txt

克隆环境(同一台机器的环境复制

conda create --name clone_env_name --clone env_name

渠道管理 添加新渠道到顶部,最高优先级

conda config --add channels new_channel
或者
conda config --prepend channels new_channel

添加新渠道到底部,最低优先级

conda config --append channels new_channel

3: PIP与Anaconda 源配置

PIP配置:

永久使用:
Linux下:
修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

windows下:
直接在user目录中创建一个pip目录,如:C:Usersxxxxpip,新建文件pip.ini,内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。

   Conda 命令行配置:

贴网址 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ 

conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes

 文件配置

然后你的.condarc 文件应该是这样的内容

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

channels: 
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 
- defaults

show_channel_urls: yes

原文地址:https://www.cnblogs.com/dgwblog/p/11811503.html