WindowsのmiseでインストールしたPythonを使うのが面倒

mise で Windows に Python もインストールした。

takatoh@sofa: w > mise ls
Tool Version Source Requested
go 1.24.3 C:\Users\takatoh\.config\mise\config.toml 1.24
node 24.1.0 C:\Users\takatoh\.config\mise\config.toml 24
python 3.13.2 C:\Users\takatoh\.config\mise\config.toml 3.13

インストールされてるパッケージを確認しようとしたら、エラーが出た。pip コマンドが使えない。

takatoh@sofa: w > pip list
pip: The term 'pip' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

次のようにしたら使えた。

takatoh@sofa: w > python -m pip list
Package Version
------- -------
pip 24.3.1

poetry をインストールしようとしたけど、pip コマンドが使えないので当然失敗する。

takatoh@sofa: w > pip install poetry
pip: The term 'pip' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

次のようにしたらインストールできた。

takatoh@sofa: w > python -m pip install poetry

さて、poetry インストール時の大量のメッセージの最後のほうに、次のようなメッセージがあった。

  WARNING: The script poetry.exe is installed in 'C:\Users\takatoh\AppData\Local\mise\installs\python\3.13.2\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

「poetry.exeは 'C:\Users\takatoh\AppData\Local\mise\installs\phton\3.13.2\Scripts'にインストールされたけどパスが通ってない。パスを通すか、この警告を無視したいなら --no-warn-script-location オプションを使え」ってことだ。

poetry だけじゃなくてほかのパッケージに関しても同じメッセージが出てる。pip コマンドが使えないのも同じ理由かも。

パスを通せば使えるようにはなるのだろうけど、そのパスの中に 3.13.2 というバージョンナンバーが入っている。ということはアップグレードするなどして別のバージョンの Python を使うときにはまたパスを通す作業をしないといけないってことだ。これは面倒だ。

かといって、python -m poetry run のようにするのも面倒だ。

さて、どうしたもんか。

[追記]

Node.js の npm コマンドは普通に使える。

takatoh@sofa: sample-project > npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (sample-project)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
type: (commonjs)
About to write to C:\Users\takatoh\Documents\w\sample-project\package.json:

{
"name": "sample-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"type": "commonjs"
}


Is this OK? (yes)

Windowsでmiseを使う

mise は限定的ながら Windows もサポートしてるそうなので、Golang をインストールするのに使ってみた。

miseのインストール

公式サイトに従って、winget でインストールする。

takatoh@sofa: Documents > winget search mise
'msstore' ソースでは、使用する前に次の契約を表示する必要があります。
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
ソースが正常に機能するには、現在のマシンの 2 文字の地理的リージョンをバックエンド サービスに送信する必要があります (例: "US")。

すべてのソース契約条件に同意しますか?
[Y] はい [N] いいえ: Y
名前 ID バージョン 一致 ソース
--------------------------------------------------------------------------------------
Divina Misericordia 9NBLGGH5X1H8 Unknown msstore
mise-en-place jdx.mise 2025.5.5 Moniker: mise winget
MiService Xiaomi.MiService 3.3.0.293 winget
Japplis Website Optimizer Japplis.WebsiteOptimizer 4.3 Tag: optimiser winget
Open-Shell Open-Shell.Open-Shell-Menu 4.4.195 Tag: customise winget

このマシンでは winget を使うのも初めてだったらしく(他のマシンでも試してみた程度しかないんだけど)、契約条件への同意を求められた。

さて、mise は ID の欄に jdx.mise とある。これをインストールする。

takatoh@sofa: Documents > winget install --id jdx.mise
見つかりました mise-en-place [jdx.mise] バージョン 2025.5.5
このアプリケーションは所有者からライセンス供与されます。
Microsoft はサードパーティのパッケージに対して責任を負わず、ライセンスも付与しません。
このパッケージには次の依存関係が必要です:
- パッケージ
Microsoft.VCRedist.2015+.x64
ダウンロード中 https://github.com/jdx/mise/releases/download/v2025.5.5/mise-v2025.5.5-windows-x64.zip
██████████████████████████████ 13.0 MB / 13.0 MB
インストーラーハッシュが正常に検証されました
アーカイブを展開しています...
アーカイブが正常に展開されました
パッケージのインストールを開始しています...
コマンド ライン エイリアスが追加されました: "mise"
パス環境変数が変更されました; 新しい値を使用するにはシェルを再起動してください。
インストールが完了しました

別のターミナルを新たに立ち上げて、試してみる。

takatoh@sofa: Documents > mise version
_ __
____ ___ (_)_______ ___ ____ ____ / /___ _________
/ __ `__ \/ / ___/ _ \______/ _ \/ __ \______/ __ \/ / __ `/ ___/ _ \
/ / / / / / (__ ) __/_____/ __/ / / /_____/ /_/ / / /_/ / /__/ __/
/_/ /_/ /_/_/____/\___/ \___/_/ /_/ / .___/_/\__,_/\___/\___/
/_/ by @jdx
2025.5.5 windows-x64 (2025-05-15)
takatoh@sofa: Documents > mise help
mise manages dev tools, env vars, and runs tasks. https://github.com/jdx/mise

Usage: mise.exe [OPTIONS] [TASK] [COMMAND]

(以下略)

大丈夫のようだ。次にmiseのアクティベート。PowerShell なので次のようにする。

takatoh@sofa: Documents > mise activate pwsh

大量に出力されるが、これを Documents\PowerShell\Mircosoft.PowerShell_profile.ps1 ファイルに貼り付ける。あるいは公式サイトにあるように次のようにする。

echo 'mise activate pwsh | Out-String | Invoke-Expression' >> $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

これで準備が終わった。Golang をインストールしよう。

takatoh@sofa: Documents > mise install [email protected]
mise [email protected] ✓ installed

mise list コマンドで確認。

takatoh@sofa: Documents > mise list
Tool Version Source Requested
go 1.24.3

go コマンドも試す。

takatoh@sofa: Documents > go version
go version go1.24.3 windows/amd64

楽なもんじゃないか。