Open7

windowsにpoetryを入れてみる。

wokwok

https://python-poetry.org/docs/#installing-with-the-official-installer

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -

でよいらしい。

※ 2024/03/27追記
pythonはMS Storeからインストールすると、どこに何がインストールされるかわからずにはまる。Python公式のインストーラでインストールするのがよい。また、その時、Path追加も自動でやってくれるようなので、チェックボックスをチェックしておくこと。

結果↓。おー簡単だった。

> (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

C:\Users\hugegegege\AppData\Roaming\Python\Scripts

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.7.1)
Installing Poetry (1.7.1): Creating environment
Actual environment location may have moved due to redirects, links or junctions.
  Requested location: "C:\Users\hugegegege\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
  Actual location:    "C:\Users\hugegegege\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Installing Poetry (1.7.1): Installing Poetry
Installing Poetry (1.7.1): Creating script
Installing Poetry (1.7.1): Done

Poetry (1.7.1) is installed now. Great!

To get started you need Poetry's bin directory (C:\Users\hugegegege\AppData\Roaming\Python\Scripts) in your `PATH`
environment variable.

Alternatively, you can call Poetry explicitly with `C:\Users\hugegegege\AppData\Roaming\Python\Scripts\poetry`.

You can test that everything is set up by executing:

`poetry --version`

wokwok

環境変数PATHにpoetryのPATHを追加。

どうやらActual location: "C:\Users\hugeg...の方を登録する必要がありそうだ。

wokwok

プロジェクトフォルダに仮想環境を作れるようにしておく

poetry config --list

で設定を確認。
virtualenvs.in-project = nullだとまだ設定されていない。

poetry config virtualenvs.in-project true

を実行

wokwok

pyinstallerでビルド.

poetry run pyinstaller test.py --onedir

fire使ってる場合は追加忘れずに。

if __name__ == "__main__":
    main
wokwok

pyenv-win

pip install pyenv-win --target $HOME\\.pyenv

アプリ実行エイリアスの設定を設定するときにはこの場所。(win11 2024/08/05では。)

[System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
[System.Environment]::SetEnvironmentVariable('PYENV_HOME',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")

[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")

ターミナルアプリを閉じて再度開き、次のコマンドを実行

pyenv --version

wokwok

pyenvによるpythonインストール

pyenv install --list
pyenv update

pyenv install --list
pyenv install 3.10.11

pyenv versions

pyenv local 3.10.11 # そのディレクトリとその配下。.python-versionファイルが作成される。
pyenv global 3.10.11 # システム全体。