0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu 24.04にminiconda環境をセットアップ

Posted at

インストーラのURLを入手

最近anacondaのページが見にくくなった。

https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

インストールして設定

conda config --add channels conda-forge
conda config --set channel_priority strict
conda config --set solver libmamba

普段はwork environmentで作業

conda create -n work python=3.13
conda activate work
conda install numpy scipy

スナップショット

conda env export --from-history > work-env.yml
  • 人が編集しやすい“仕様書”。あなたが明示的に入れたパッケージ名・バージョンだけ(依存は省略)
    • 利点: 余計な依存が入らず可搬性◎、あとで編集しやすい
    • 欠点: これだけだと完全再現にならない(解決結果は時期で変わる)
conda env export > work-env-full.yml
  • その時点の“ほぼロック”。依存まで含めてバージョン(場合によってはビルド)まで固定。pipで入れたものは pip: セクションに入る。
    • 利点: 同じOS/archなら再現性が高い
    • 欠点: プラットフォーム差で壊れやすい/冗長(可搬性△)。必要なら --no-builds を付けて少し緩めに。
pip freeze > requirements.txt
  • pip/venv 用の“pip専用ロック”conda 環境の共有には基本不要
    • 利点: pip だけで再現したい相手に渡すとき
    • 欠点: conda 側のネイティブ依存は一切表現できない(conda 環境の再現には使えない)

スナップショットの復元

  • 仕様書から(解決はその時点で再計算)
 conda env create -f work-env.yml -n work
  • フルYAMLから(その時点に近い状態へ)
 conda env create -f work-env-full.yml -n work
  • pip-only で渡す相手向け
 python -m venv .venv && source .venv/bin/activate
 pip install -r requirements.txt
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?