Windowsに限った話なのかわかりませんが、VSCode上でshift + enterでプログラムをPython REPLに送って実行しようとすると、インデントが崩れてしまい、実用になりません。調べてみると、Python 3.13のREPLでインデントの処理に変化があり、それにVSCodeのPython Extensionがまだ対応できていないみたいです。
最新バージョンのPythonが必要なわけではないので、Python 3.12に戻すことにしました。Windowsのscoop(Macのhomebrewに相当)を使っているので、以下のようにやってみました。まず、bucketにversionsを登録してからpythonを検索します。
scoop bucket add versions scoop search python
すると以下のように、使用できるバージョンが表示されます。
Name Version Source Binaries ---- ------- ------ -------- pulumi 3.181.0 main pulumi-analyzer-policy-python.cmd | pulumi-language-python-... python 3.13.5 main winpython 3.12.10.0 main anaconda2 2019.10 versions python.exe | pythonw.exe | python.exe anaconda3-2022.05 2022.05 versions python.exe | pythonw.exe | python.exe miniconda2 4.8.3 versions python.exe | pythonw.exe | python.exe miniconda3-4.12.0 4.12.0 versions python.exe | pythonw.exe | python.exe miniconda3-py310 25.5.1-0 versions python.exe | pythonw.exe | python.exe miniconda3-py311 25.5.1-0 versions python.exe | pythonw.exe | python.exe miniconda3-py37 23.1.0-1 versions python.exe | pythonw.exe | python.exe miniconda3-py38 23.11.0-2 versions python.exe | pythonw.exe | python.exe miniconda3-py39 25.5.1-0 versions python.exe | pythonw.exe | python.exe python-alpha 3.14.0b3 versions python-beta 3.14.0b3 versions python-pre 3.14.0b3 versions python-rc 3.13.0rc3 versions python27 2.7.18 versions python310 3.10.11 versions python311 3.11.9 versions python312 3.12.10 versions python313 3.13.5 versions python35 3.5.4 versions python36 3.6.8 versions python37 3.7.9 versions python38 3.8.10 versions python39 3.9.13 versions winpython37 3.7.7.1 versions winpython3741 3.7.4.1 versions winpython37cod 3.7.7.1 versions winpython37ps2 3.7.6.0 versions winpython38 3.8.9.0 versions winpython38cod 3.8.7.0 versions winpython38ps2 3.8.1.0 versions
自分が使いたいのはPython 3.12なので、以下のようにpython312をインストールします。
scoop install python312
VSCodeでのインデントの問題も解消され、また気持ちよくプログラミングできるようになりました。
ただ、Google Driveの中に置いたvenv内でpip installがうまくいきません。パス名の中にスペースが入っているのがいけないのか、それとも「マイドライブ」という2バイト文字がだめなのか……。「D:\python」以下では問題がないので、Google Driveとの相性なんでしょう。(Python 3.13では大丈夫だったので、なにかが変わったんですね)