前提
poetryを使ったことがある人のために記載します。
Poetryの始め方はこちらに詳しく書いてあります。
参考 【Python】Poetry始めてみた & Pipenv から poetry へ移行した所感Qiita今回は、slackというフォルダをつくりました。
(ややこしいフォルダ名ですいません。)
poetry new slack
poetry install
これで準備完了です。
Pythonのversionがpython2になっている
poetyをつかったところ、こんなエラーが発生しました。
poetry run python
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
以下のコマンドで仮想環境の状況を確認します。
poetry env info
Virtualenv
Python: 2.7.16
Implementation: CPython
Path: /Users/xxxxxxx/Desktop/slack/.venv
Valid: True
System
Platform: darwin
OS: posix
Python: /System/Library/Frameworks/Python.framework/Versions/2.7
やはりPython2.7.16が表示されています。
トライしてみるも失敗
以下のコードを試してみます。
poetry env use 3.8
赤字でエラーが出てしまいました。
[NoCompatiblePythonVersionFound]
The specified Python version (3.8.0) is not supported by the project (^2.7).
Please choose a compatible version or loosen the python constraint specified in the pyproject.toml file.
Python3に変更できた手順
pyproject.tomlの変更
フォルダの中にある、pyproject.tomlの
python2の記述を修正します。
python2.@.→python3.@
今回は、python3.8に変更しました。
以下の画像を参考にしてください。

poetry env use 3.8の実行
先ほどは失敗しましたが、改めてpython3.8に変更をします。
poetry env use 3.8
Recreating virtualenv slack in /Users/xxxxxxxxxxxxx/Desktop/slack/.venv
Using virtualenv: /Users/xxxxxxxxxxxxxx/Desktop/slack/.venv
変更できたようです。
確認してみます。
poetry env info
Virtualenv
Python: 3.8.0
Implementation: CPython
Path: /Users/xxxxxxxxxx/Desktop/slack/.venv
Valid: True
System
Platform: darwin
OS: posix
Python: /Library/Frameworks/Python.framework/Versions/3.8
やりました!無事に変更ができました。
まとめ
やれば簡単でしたが、情報がなくて困惑しました。
1時間ぐらいかかってしまったのですが、
python2から3へ変更したくて、
つまづいた方がいれば、ぜひ参考にしてみてください。