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:\Users\xxxx\pip,新建文件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