#author("2024-02-26T20:21:04+00:00","default:mizutu","mizutu")
#author("2024-03-16T22:56:15+00:00","default:mizutu","mizutu")
[[私的AI研究会]] > CondaReview
*【復習】Anaconda &color(green){= 編集中 =}; [#w679f9ff]
*【復習】Anaconda [#dc052630]
#ref(画像一覧/anaconda-logo.png,right,around,40%,anaconda-logo.png)
#ref(画像一覧/pypi_logo.png,right,around,40%,pypi_logo.png)
 「Anaconda」の使い方をもう一度復習する。~
#divregion( 目 次)
#divregion( 目 次,open)
#contents
#enddivregion
#clear
RIGHT:&size(12){※ 最終更新:2024/02/27 };
RIGHT:&size(12){※ 最終更新:2024/03/17 };

** 予備知識 [#m06b09ea]
 Python によるソフトウェア開発では、これまでのPython利用者たちが作り上げた、膨大なソフトウェア資産とそれらを利用できる環境が2種類用意されている。~

** Anaconda 開発環境 概要 [#w355becf]
*** PyPI (The Python Package Index) [#c9fcf823]
- PyPIはPython言語の開発コミュニティである Python Software Foundation(PSF) が運営する、Python用ソフトウェアの公開サービスで、だれでも自由に自分のソフトウェアを登録して公開できる。~
- 公開されているPythonソフトウェアのほとんどは、PyPIから入手できる。~
- PSFが提供する公式版のPythonは、PyPIからソフトウェアを取得する pip というツールを標準で含んでいる。~

*** Anaconda [#nd1e8dcd]
- Anaconda社が提供するデータサイエンスをはじめとする科学技術計算のためのプラットフォームを利用する。~
- Anacondaは、独自にAnaconda用のソフトウェア資産の公開サービスを運営しており、データサイエンス用のソフトウェアなどを中心に、多くのソフトウェアが利用できるようになっている。~
- PyPIで公開されているソフトウェアも、主要なソフトウェアはAnacondaにも登録されている。~
- Anacondaからソフトウェアを取得する時は、conda というツールを使う。~

*** CondaとPIP [#j97b8b5e]
- 基本的には、Anacondaの環境を利用する場合には conda を使い、Anacondaを使わない場合には pip を使う。~
(conda は、Anaconda以外の環境では使えない。)~
- Anacondaの環境では ''pip3 install'' を実行する前に、''conda search'' コマンドなどで必要なパッケージを検索して、''conda install'' コマンドでインストールできないか調べる必要がある。~
- ''conda'' と ''pip'' はそれぞれ独立してパッケージのインストール環境を管理している。%%このため、Anaconda環境で pip を使ってパッケージをインストールすると、パッケージの依存関係の管理に不具合が発生してしまう場合がある。%%~

- ''pip''ではパッケージインストールの際に、都度すべての依存関係が同時に満たされるようにはしていないよう。インストールしたパッケージ間でそれぞれが依存するパッケージのバージョンが異なると衝突が起こることがある。~

- ''conda'' では全パッケージのメタデータを収集して依存関係を把握するSAT solverというものを備えており、これに対応している。 インストールの際は、 パッケージ間の複雑な依存関係を素早く把握し、適切な更新・インストールを行う。~

*** 仮想環境 conda と venv [#ndb2b5c7]
- 公式版Pythonでは、仮想環境は ''venv'' を使って作成し、仮想環境へのパッケージのインストールは ''pip'' コマンドで行う。~
- Anacondaでは、仮想環境の作成とパッケージのインストールは両方とも ''conda'' コマンドで行う。(''pip'' も使用可)~
| |CENTER:140|CENTER:140|c
|CENTER:種 別|Python|Anaconda|h
|パッケージインストール|pip|conda|
|依存関係のチェック|なし|あり|
|パッケージのダウンロード元|PyPl|anacondaリポジトリ|
|仮想環境|venv|conda|
#clear
#br

** 更新履歴 [#n29a09b8]
** Anaconda 概要 [#lf685610]
- [[Python 統合開発環境としての「Anaconda」>Anaconda1]]~

*** conda主要コマンド [#he530746]
|>|CENTER:機 能|CENTER:コマンド|h
|パケージ一覧表示|BGCOLOR(lightyellow):現在の仮想環境のパッケージ一覧表示|BGCOLOR(lightyellow):conda list|
|~|指定した仮想環境のパッケージ一覧表示|conda list -n py38|
|パッケージの検索|BGCOLOR(lightyellow):公式リポジトリ内のパッケージを検索|BGCOLOR(lightyellow):conda search tensorflow|
|~|チャネル内のパッケージを検索|conda search -c conda-forge tensorflow|
|パッケージインストール|BGCOLOR(lightyellow):公式リポジトリ内のパッケージをインストール|BGCOLOR(lightyellow):conda install tensorflow|
|~|チャネル内のパッケージをインストール|conda install -c conda-forge  tensorflow|
|~|バージョン指定してインストール|conda install tensorflow=1.15|
|パッケージの更新|BGCOLOR(lightyellow):パッケージを最新に|BGCOLOR(lightyellow):conda update tensorflow|
|~|すべてのパッケージを最新に|conda update --all|
|>|BGCOLOR(lightyellow):パケージのアンインストール|BGCOLOR(lightyellow):conda uninstall tensorflow|
|>|パケージの削除|conda remove tensorflow|
|仮想環境作成|BGCOLOR(lightyellow):pythonバージョンを指定して作成|BGCOLOR(lightyellow):conda create -n py38 python=3.8|
|~|BGCOLOR(khaki):仮想環境をコピーして作成|BGCOLOR(khaki):conda create -n py38 --clone base|
|~|環境設定ファイル(.yaml)から環境を再構築|conda create -n py38 --file package-list.txt|
|>|BGCOLOR(lightyellow):仮想環境の削除|BGCOLOR(lightyellow):conda env remove -n py38|
|>|BGCOLOR(lightyellow):仮想環境有効化|BGCOLOR(lightyellow):conda activate py38|
|>|BGCOLOR(lightyellow):仮想環境の終了|BGCOLOR(lightyellow):conda deactivate|
|>|現在の環境を設定ファイル(.yaml)に出力|conda list --export > package-list.txt|
|>|conda のアップデート|conda update -n base conda|
|>|BGCOLOR(lightyellow):condaのバージョンを表示|BGCOLOR(lightyellow):conda -V|
|>|BGCOLOR(lightyellow):仮想環境の一覧表示|BGCOLOR(lightyellow):conda info -e|
|>|conda 環境の表示|conda info|

*** pip/pip3 の主要コマンド [#d257bb03]
|CENTER:機 能|CENTER:コマンド|h
|インストール済みのパッケージの詳細確認|pip show <パッケージ名>|
|インストール済みパッケージ名とバージョン一覧|pip list|
|最新版になっていないもののみ表示|pip list –outdate|
|インストール済みパッケージ名とバージョン一覧(パッケージ管理除外)|pip freeze|
|BGCOLOR(lightyellow):パッケージのインストール|BGCOLOR(lightyellow):pip install <パッケージ名>|
|複数パッケージのインストール|pip install <パッケージ名> <パッケージ名> ...|
|BGCOLOR(lightyellow):バージョンを指定してインストール&br;(バージョンを省略するとインストール可能なバージョン表示)|BGCOLOR(lightyellow):pip install <パッケージ名>==<バージョン>|
|GitHab からインストール|pip install git+<repository-url>|
|パッケージのアップデート|pip install -U <パッケージ名>|
|パッケージのアップデート|pip install –update <パッケージ名>|
|BGCOLOR(lightyellow):インストール済みパッケージのアンインストール|BGCOLOR(lightyellow):pip uninstall <パッケージ名>|
|複数インストール済みパッケージのアンインストール|pip uninstall <パッケージ名> <パッケージ名> ... |
|最新ファイルをDL(インストールはしない)|pip download <パッケージ名>|
|BGCOLOR(lightyellow):pipのバージョンを表示|BGCOLOR(lightyellow):pip -V|
|pipの主要コマンドとオプション一覧を表示|pip help|
|pip コマンドの内容とオプションを表示|pip <コマンド> -h|

*** 仮想環境について [#z731396d]
- 一覧を表示する~
#codeprettify(){{
(base) > conda info -e
# conda environments:
#
base                  *  C:\Users\<User>\anaconda3
openvino_dev             C:\Users\<User>\anaconda3\envs\openvino_dev
py37                     C:\Users\<User>\anaconda3\envs\py37
py38                     C:\Users\<User>\anaconda3\envs\py38
py38_gan                 C:\Users\<User>\anaconda3\envs\py38_gan
py38a                    C:\Users\<User>\anaconda3\envs\py38a
py_learn                 C:\Users\<User>\anaconda3\envs\py_learn
}}
    ↑      ↑     ↑~
  仮想環境名  現在の環境 仮想環境ディレクトリの場所~
~
- 仮想環境は下記コマンドの1行目の場所に生成される
#codeprettify(){{
(base) PS > conda config --show envs_dirs
envs_dirs:
  - C:\Users\<User>\anaconda3\envs
  - C:\Users\<User>\.conda\envs
  - C:\Users\<User>\AppData\Local\conda\conda\envs
}}
・下記 conda info コマンドでも確認できる~
・「conda config」により変更が可能~

*** anaconda の設定環境 [#g21cc2e6]
- 現在の設定を表示する~
#codeprettify(){{
(base) PS > conda info

     active environment : base
    active env location : C:\Users\<User>\anaconda3
            shell level : 1
       user config file : C:\Users\<User>\.condarc
 populated config files :
          conda version : 24.1.2
    conda-build version : 24.1.2
         python version : 3.9.18.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=x86_64
                          __conda=24.1.2=0
                          __win=0=0
       base environment : C:\Users\<User>\anaconda3  (writable)
      conda av data dir : C:\Users\<User>\anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\<User>\anaconda3\pkgs
                          C:\Users\<User>\.conda\pkgs
                          C:\Users\<User>\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\<User>\anaconda3\envs
                          C:\Users\<User>\.conda\envs
                          C:\Users\<User>\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.1.2 requests/2.31.0 CPython/3.9.18 Windows/10 Windows/10.0.22631 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.6 aau/0.4.3 c/5snNlqzWCTJlZJsEo_5Qkg s/1b_caiWUs1MvdUtXNMyTaw e/kIf1P1TTAzJXAN1T4PJ4Zg
          administrator : False
             netrc file : None
           offline mode : False
}}

***(参考) conda 環境の設定・確認 [#e7f8c1b6]
- anaconda の構成ファイル「.condarc」~
・「conda config --show-sources」で確認できる(初期状態では存在しない)~
~
- 設定・確認コマンド「conda config」~
・各種パラメータ指定により動作変更が可能~
~
#divregion(「conda config -h」実行ログ)
#codeprettify(){{
(base) PS > conda config -h
usage: conda-script.py config [-h] [--json] [-v] [-q] [--system | --env | --file FILE] [--show [SHOW ...] |
                              --show-sources | --validate | --describe [DESCRIBE ...] | --write-default]
                              [--get [KEY ...] | --append KEY VALUE | --prepend KEY VALUE | --set KEY VALUE | --remove
                              KEY VALUE | --remove-key KEY | --stdin]

Modify configuration values in .condarc.

This is modeled after the git config command.  Writes to the user .condarc
file (C:\Users\<User>\.condarc) by default. Use the
--show-sources flag to display all identified configuration locations on
your computer.

optional arguments:
  -h, --help            Show this help message and exit.

Output, Prompt, and Flow Control Options:
  --json                Report all output as json. Suitable for using conda programmatically.
  -v, --verbose         Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG
                        logging, four times for TRACE logging.
  -q, --quiet           Do not display progress bar.

Config File Location Selection:
  Without one of these flags, the user config file at 'C:\Users\<User>\.condarc' is used.

  --system              Write to the system .condarc file at 'C:\Users\<User>\anaconda3\.condarc'.
  --env                 Write to the active conda environment .condarc file (C:\Users\<User>\anaconda3). If no
                        environment is active, write to the user config file (C:\Users\<User>\.condarc).
  --file FILE           Write to the given file.

Config Subcommands:
  --show [SHOW ...]     Display configuration values as calculated and compiled. If no arguments given, show
                        information for all configuration values.
  --show-sources        Display all identified configuration sources.
  --validate            Validate all configuration sources. Iterates over all .condarc files and checks for parsing
                        errors.
  --describe [DESCRIBE ...]
                        Describe given configuration parameters. If no arguments given, show information for all
                        configuration parameters.
  --write-default       Write the default configuration to a file. Equivalent to `conda config --describe >
                        ~/.condarc`.

Config Modifiers:
  --get [KEY ...]       Get a configuration value.
  --append KEY VALUE    Add one configuration value to the end of a list key.
  --prepend KEY VALUE, --add KEY VALUE
                        Add one configuration value to the beginning of a list key.
  --set KEY VALUE       Set a boolean or string key.
  --remove KEY VALUE    Remove a configuration value from a list key. This removes all instances of the value.
  --remove-key KEY      Remove a configuration key (and all its values).
  --stdin               Apply configuration information given in yaml format piped through stdin.

See `conda config --describe` or https://conda.io/docs/config.html
for details on all the options that can go in .condarc.

Examples:

Display all configuration values as calculated and compiled::

    conda config --show

Display all identified configuration sources::

    conda config --show-sources

Print the descriptions of all available configuration
options to your command line::

    conda config --describe

Print the description for the "channel_priority" configuration
option to your command line::

    conda config --describe channel_priority

Add the conda-canary channel::

    conda config --add channels conda-canary

Set the output verbosity to level 3 (highest) for
the current activate environment::

    conda config --set verbosity 3 --env

Add the 'conda-forge' channel as a backup to 'defaults'::

    conda config --append channels conda-forge
}}
#enddivregion
#divregion(「conda config --show」実行ログ)
#codeprettify(){{
(base) >conda config --show
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
allowlist_channels: []
always_copy: False
always_softlink: False
always_yes: None
anaconda_anon_usage: True
anaconda_upload: None
auto_activate_base: True
auto_stack: 0
auto_update_conda: True
bld_path:
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: flexible
channel_settings: []
channels:
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
conda_build: {}
create_default_packages: []
croot: C:\Users\<User>\anaconda3\conda-bld
custom_channels:
  pkgs/main: https://repo.anaconda.com
  pkgs/r: https://repo.anaconda.com
  pkgs/msys2: https://repo.anaconda.com
  pkgs/pro: https://repo.anaconda.com
custom_multichannels:
  defaults:
    - https://repo.anaconda.com/pkgs/main
    - https://repo.anaconda.com/pkgs/r
    - https://repo.anaconda.com/pkgs/msys2
  local:
debug: False
default_channels:
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - https://repo.anaconda.com/pkgs/msys2
default_python: 3.9
default_threads: None
deps_modifier: not_set
dev: False
disallowed_packages: []
download_only: False
dry_run: False
enable_private_envs: False
env_prompt: ({default_env})
envs_dirs:
  - C:\Users\<User>\anaconda3\envs
  - C:\Users\<User>\.conda\envs
  - C:\Users\<User>\AppData\Local\conda\conda\envs
error_upload_url: https://conda.io/conda-post/unexpected-error
execute_threads: 1
experimental: []
extra_safety_checks: False
fetch_threads: 5
force: False
force_32bit: False
force_reinstall: False
force_remove: False
ignore_pinned: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
migrated_custom_channels: {}
no_lock: False
no_plugins: False
non_admin_enabled: True
notify_outdated_conda: True
number_channel_notices: 5
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pip_interop_enabled: False
pkgs_dirs:
  - C:\Users\<User>\anaconda3\pkgs
  - C:\Users\<User>\.conda\pkgs
  - C:\Users\<User>\AppData\Local\conda\conda\pkgs
proxy_servers: {}
quiet: False
register_envs: True
remote_backoff_factor: 1
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
repodata_fns:
  - current_repodata.json
  - repodata.json
repodata_threads: None
repodata_use_zst: True
report_errors: None
restore_free_channel: False
rollback_enabled: True
root_prefix: C:\Users\<User>\anaconda3
safety_checks: warn
sat_solver: pycosat
separate_format_cache: False
shortcuts: True
shortcuts_only: []
show_channel_urls: None
signing_metadata_url_base: None
solver: libmamba
solver_ignore_timestamps: False
ssl_verify: True
subdir: win-64
subdirs:
  - win-64
  - noarch
target_prefix_override:
trace: False
track_features: []
unsatisfiable_hints: True
unsatisfiable_hints_check_depth: 2
update_modifier: update_specs
use_index_cache: False
use_local: False
use_only_tar_bz2: False
verbosity: 0
verify_threads: 1
}}
#enddivregion

*** anaconda アンインストール [#yee3ee73]
 &color(white,black){'' Windows の場合 ''};~
+「プログラムの追加と削除」から「Anaconda3 ... 」をアンインストールする~
`
+ 下記の anaconda 関連ディレクトリに残っているフォルダ(ファイル)があればすべて削除する~
#codeprettify(){{
C:\ProgramData\Anaconda3
C:\Users\<User>\.conda
C:\Users\<User>\AppData\Local\conda
C:\Users\<User>\anaconda3
}}
※ バージョンによって関連ディレクトリの場所は異なる~

*** anaconda のダウンロードとインストール [#ud123928]
 &color(white,black){'' Windows の場合 ''};~
+ オフィシャルサイト [['''https://www.anaconda.com/products/distribution'''>+https://www.anaconda.com/products/distribution]] にアクセス~
~
#ref(ProjectEnv2/inst_ubuntu2204_30.jpg,left,around,15%,inst_ubuntu2204_30.jpg)
 ● 画面の「Download」ボタンを押してダウンロード~
~
 ● ダウンロード・ファイル名(2024/02/29 現在)~
  '''Anaconda3-2023.09-0-Linux-x86_64.sh'''~
#clear
~
+ インストーラ「Anaconda3-2023.09-0-Windows-x86_64.exe」を実行し手順に従ってインストールする~
~
#ref(ProjectEnv/20230202_000002_001s.jpg,left,around,30%,20230202_000002_001s.jpg)
#ref(ProjectEnv/20230202_000003_001s.jpg,left,around,30%,20230202_000003_001s.jpg)
#ref(ProjectEnv/20230202_000004_001s.jpg,left,around,30%,20230202_000004_001s.jpg)
#ref(ProjectEnv/20230202_000005_001s.jpg,left,around,30%,20230202_000005_001s.jpg)
#clear
#ref(ProjectEnv/20230202_000006_001s.jpg,left,around,30%,20230202_000006_001s.jpg)
#ref(ProjectEnv/20230202_000008_001s.jpg,left,around,30%,20230202_000008_001s.jpg)
#ref(ProjectEnv3/20231215_043714_001s.jpg,left,around,30%,20231215_043714_001s.jpg)
#ref(ProjectEnv/20230202_000010_001s.jpg,left,around,30%,20230202_000010_001s.jpg)
#clear
※ デフォールト設定でインストールする~

*** anaconda 起動の設定 [#xecdeffc]
- アプリケーションの実行時に便利なようにターミナル起動時の設定をしておく。~

 &color(white,black){'' Windows の場合 ''};~
#ref(CondaWin/20220107_000001_001s.jpg,left,around,20%,20220107_000001_001s.jpg)
#ref(CondaWin/20220107_000002_001s.jpg,left,around,20%,20220107_000002_001s.jpg)
#clear

 ''≪ PowerShell(推奨)≫''~
+「スタートボタン」を押し「Anaconda Powershell Prompt (anaconda3)」の上で 右クリック → その他 → ファイルの場所を開く を選択する。~
+ 表示されるエクスプローラ上の「Anaconda Powershell Prompt (anaconda3)」で 右クリック → プロパティ を選ぶ。~
+ リンク先の項目を変更する。~
・元の記述~
#codeprettify(){{
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\<User>\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\<User>\anaconda3' "
}}
・次のように変更 <User> = ユーザー名 X: = anaconda_winを配置したドライブ~
#codeprettify(){{
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\<User>\anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\<User>\anaconda3'; Set-Location 'X:\anaconda_win' "
}}

 ''≪ コマンドプロンプト ≫''~
+「Anaconda Prompt (anaconda3)」で 右クリック → プロパティ を選ぶ。~
+ リンク先の項目を変更する。~
・元の記述~
#codeprettify(){{
%windir%\System32\cmd.exe "/K" C:\Users\<User>\anaconda3\Scripts\activate.bat C:\\Users\<User>\anaconda3
}}
・次のように変更 <User> = ユーザー名 X: = anaconda_winを配置したドライブ~
#codeprettify(){{
%windir%\System32\cmd.exe "/K" C:\Users\<User>\anaconda3\Scripts\activate.bat C:\\Users\<User>\anaconda3 & cd /d X:\anaconda_win
}}

*** anaconda を最新版にアップデート [#y9d8b36a]
- 更新を促すメッセージ~
#codeprettify(){{
==> WARNING: A newer version of conda exists. <==
  current version: 23.7.4
  latest version: 24.1.2

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=24.1.2
}}
+ インストールされているすべてのパッケージを最新バージョンにアップデートする~
#codeprettify(){{
(base) PS > conda update --all
}}
+ Conda(Anacondaのパッケージマネージャー)をコマンドでアップデート~
#codeprettify(){{
(base) PS > conda update conda
}}
+ anaconda を再起動してバージョン確認~
#codeprettify(){{
(base) PS > conda -V
}}
※ conda 24.1.2 (2024/03/02 現在)

*** ファイルシステムと anaconda の配置 [#k00690c1]
 &color(white,black){'' Windows の場合 ''};~
- Windows ではドライブは独立しその下にフォルダ・ファイルが配置される~
#ref(filesystem_w_m.png,left,around,60%,filesystem_w_m.png)
#clear
※ プロジェクトのフォルダはドライブ直下の「anaconda_win/」にする~

 &color(white,black){'' Linux の場合 ''};~
- Linux では root フォルダの下にフォルダが置かれ、ドライブはマウントされたフォルダとして配置される~
#ref(filesystem_l_m.png,left,around,60%,filesystem_l_m.png)
#clear
※ プロジェクトのフォルダはユーザーのホームディレクトリ「~/」にする~

*** PowerSell の設定 [#h4fb443a]
- PowerShellでプロファイル(profile)を作成しておくと、PowerShellの起動時に実行させることができる~
使用する頻度の高い処理をエイリアスや関数にしてプロファイルに保存しておく~
- Linux の 'which' コマンドを作成してみる~

+ 実行権限を設定する~
・管理者として「Windows PowerShell」を起動して次のコマンドを実行~
#codeprettify(){{
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
}}
+ プロファイルの作成~
・プロファイルが作成される場所を確認~
#codeprettify(){{
$profile
}}
・プロファイルが存在しなければ作成~
#codeprettify(){{
new-item -path $profile -itemtype file -force
}}
※「Microsoft.PowerShell_profile.ps1」という空のファイルが作成される~
~
+ ファイル「Microsoft.PowerShell_profile.ps1」を修正する~
・C:\Users\<User>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
#codeprettify(){{
# PowerShell 動作確認
echo 'Windows PowerShell'
Get-Host

# 'which' command
function which($cmdname) {
  Get-Command $cmdname | Select-Object -ExpandProperty Definition
}
}}
+「PowerShell」「Anaconda PowerShell」を再起動する~
#codeprettify(){{
Windows PowerShell

Name             : ConsoleHost
Version          : 5.1.22621.2506
InstanceId       : 3ef6a3c4-1c1f-406d-8fe5-cec8caadc939
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : ja-JP
CurrentUICulture : ja-JP
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

(base) PS C:\anaconda_win>
}}
+ 'wkich': コマンドの実行パスを調べる~
#codeprettify(){{
(base) PS > which ls
Get-ChildItem
(base) PS > which python
C:\Users\izuts\anaconda3\python.exe
}}


#br

** 更新履歴 [#oce8b9a5]
- 2024/02/27 初版
#br

* 参考資料 [#i0809bde]
* 参考資料 [#a2f5a893]
- Anaconda~
-- [[condaコマンドチートシート>+https://qiita.com/Kotabrog/items/1262057349627b299321]]~
-- [[Uninstalling Anaconda Distribution>+https://docs.anaconda.com/free/anaconda/install/uninstall/]]~
-- [[Condaのチャンネルとは?>+https://qiita.com/yuj/items/8ce25959427ea97d373b]]~
-- [[Using the .condarc conda configuration file>+https://conda.io/docs/config.html]]~
-- [[かかしのアウトプット練習>+https://kakashibata.hatenablog.jp/entry/2020/09/27/222205]]~
-- [[Anacondaを最新バージョンにアップデートする【Python】>+https://consulting-campus.site/update-anaconda-to-latest-version/]]~

- PowerShell~
-- [[PowerShellでLinuxのwhichコマンドを作る>+https://tex2e.github.io/blog/powershell/which]]~
-- [[PowerShellでプロファイルを作成する方法>+https://www.zacoding.com/post/powershell-profile/]]~

#br