LoginSignup
15
30

More than 1 year has passed since last update.

[Python] conda仮想環境構築でよく使うコマンド一覧

Last updated at Posted at 2022-07-14

conda

AnacondaおよびMinicondaの環境構築に関して、
よく利用したコマンドをまとめた。適宜追記する。
なお、環境の移行の方法は以下の記事へ。

対象

各対象として仮想環境、チャンネル、パッケージに対して、
よく使用するコマンドをまとめた。

仮想環境

仮想環境の構築及び確認のためのコマンドをまとめた。

目的 コマンド
一覧 conda info -e
一覧 conda env list
パス conda info –base
作成 conda create -n [仮想環境名]
作成※1 conda env create -n [仮想環境名] -f [ファイル名]
移行 conda activate [仮想環境名]
離脱 conda deactivate
削除 conda remove -n [仮想環境名] --all

※1 ファイルから環境を構築する場合

詳細設定例は以下の通り。

目的 コマンド
作成 conda create -n [仮想環境名] python=[pythonバージョン名]

チャンネル

チャンネル追加、削除のためのコマンドをまとめた。
なお、チャンネルとは、パッケージをダウンロードする際のリポジトリ名のこと。
基本的に初期のチャンネルは[default]であって、[http://conda.anaconda.org/] である。

目的 コマンド
一覧 conda config --get
一覧 conda config --show channels
追加※1 conda config --add channels [チャンネル名]
追加※2 conda config --append channels [チャンネル名]
削除 conda config --remove channels [チャンネル名]

※1 追加したチャンネルの優先順位を最高にする
※2 追加したチャンネルの優先順位を最低にする

パッケージ

パッケージ確認、追加、削除のためのコマンドをまとめた。

目的 コマンド
一覧 connda list
追加 conda install [パッケージ名]
削除 conda uninstall [パッケージ名]

パッケージ追加の詳細設定例は以下の通り。

目的 コマンド
バージョン指定 conda install [パッケージ名]==[バージョン]
チャンネル指定 conda install [パッケージ名] -c [チャンネル名]
チャンネル指定(※1) conda install [パッケージ名] -c [チャンネル名] --override-channels

※1:他のチャンネルを検索しない

動作

動作別でのよく使用するコマンド。
区分けが違うので前述と重複の場合あり。

バージョン確認

目的 コマンド
python python -V
conda conda -V

アップデート

目的 コマンド
conda conda update conda
仮想環境 conda update -n [仮想環境名]
パッケージ conda update --all
特定パッケージ conda update [パッケージ名]
15
30
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
30