概要
- 以下の記事で
openssl@1.1
を削除しましたが、その影響でpoetry
が使用できなくなりました。
7rikazhexde-techlog.hatenablog.com
- 可能性として、
python3.10
系とopenssl@1.1
に依存関係があるため、少なくともopenssl@3
を使用する場合はpythonのバージョン上げる必要があることがわかりました。 - そこで、問題の解消のため
poetry
を再インストール(アンインストール → インストール)しました。
実行環境
% sw_vers ProductName: macOS ProductVersion: 13.6.1 BuildVersion: 22G313 % brew --version Homebrew 4.1.17 % poetry --version Poetry (version 1.6.1)
現象
poetry self updateでエラー
<注意事項>ログは欠けている可能性があります。
% poetry self update Traceback (most recent call last): File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 327, in run exit_code = self._run(io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 190, in _run exit_code: int = super()._run(io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 378, in _run name = self._get_command_name(io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 610, in _get_command_name if self.has(candidate): File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 232, in has self._command_loader.has(name) and self.add(self._command_loader.get(name)) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/loaders/factory_command_loader.py", line 34, in get return factory() File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 44, in _load module = import_module("poetry.console.commands." + ".".join(words)) File "$HOME/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/self/update.py", line 8, in <module> from poetry.console.commands.add import AddCommand File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/add.py", line 13, in <module> from poetry.console.commands.init import InitCommand File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/init.py", line 16, in <module> from poetry.utils.dependency_specification import RequirementsParser File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/dependency_specification.py", line 19, in <module> from poetry.packages.direct_origin import DirectOrigin File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/packages/direct_origin.py", line 10, in <module> from poetry.inspection.info import PackageInfo File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/inspection/info.py", line 26, in <module> from poetry.utils.env import EnvCommandError File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env/__init__.py", line 9, in <module> from poetry.utils.env.base_env import Env File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env/base_env.py", line 15, in <module> from virtualenv.seed.wheels.embed import get_embed_wheel File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/__init__.py", line 3, in <module> from .run import cli_run, session_via_cli File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/run/__init__.py", line 11, in <module> from ..seed.wheels.periodic_update import manual_upgrade File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-
poetry new コマンドでもエラー
どうやらpython 3.10/3.10.4
でopenssl@1.1
を使用しているが見つからないのでエラーになっているという状況でした。
これはopenssl@1.1
をアンインストールしたことによる影響でした。
% poetry new my_project Traceback (most recent call last): File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 327, in run exit_code = self._run(io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 190, in _run exit_code: int = super()._run(io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 431, in _run exit_code = self._run_command(command, io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 473, in _run_command raise error File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 454, in _run_command self._event_dispatcher.dispatch(command_event, COMMAND) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/events/event_dispatcher.py", line 26, in dispatch self._do_dispatch(listeners, event_name, event) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/events/event_dispatcher.py", line 89, in _do_dispatch listener(event, event_name, self) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 283, in configure_env from poetry.console.commands.self.self_command import SelfCommand File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/self/self_command.py", line 13, in <module> from poetry.utils.env import EnvManager File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env/__init__.py", line 9, in <module> from poetry.utils.env.base_env import Env File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env/base_env.py", line 15, in <module> from virtualenv.seed.wheels.embed import get_embed_wheel File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/__init__.py", line 3, in <module> from .run import cli_run, session_via_cli File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/run/__init__.py", line 11, in <module> from ..seed.wheels.periodic_update import manual_upgrade File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/__init__.py", line 3, in <module> from .acquire import get_wheel, pip_wheel_env_run File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/acquire.py", line 11, in <module> from .bundle import from_bundle File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/bundle.py", line 4, in <module> from .periodic_update import periodic_update File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/periodic_update.py", line 11, in <module> import ssl File "$HOME/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ImportError: dlopen($HOME/.pyenv/versions/3.10.4/lib/python3.10/lib-dynload/_ssl.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib Referenced from: [参照先情報] $HOME/.pyenv/versions/3.10.4/lib/python3.10/lib-dynload/_ssl.cpython-310-darwin.so Reason: tried: '/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/usr/local/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file, not in dyld cache) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "$HOME/Library/Python/3.10/bin/poetry", line 10, in <module> sys.exit(main()) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 405, in main exit_code: int = Application().run() File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py", line 338, in run self.render_error(e, io) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 180, in render_error self.set_solution_provider_repository(self._get_solution_provider_repository()) File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py", line 394, in _get_solution_provider_repository from poetry.mixology.solutions.providers.python_requirement_solution_provider import ( # noqa: E501 File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/mixology/solutions/providers/__init__.py", line 3, in <module> from poetry.mixology.solutions.providers.python_requirement_solution_provider import ( File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/mixology/solutions/providers/python_requirement_solution_provider.py", line 9, in <module> from poetry.puzzle.exceptions import SolverProblemError File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/puzzle/__init__.py", line 3, in <module> from poetry.puzzle.solver import Solver File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/puzzle/solver.py", line 16, in <module> from poetry.puzzle.provider import Indicator File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/puzzle/provider.py", line 27, in <module> from poetry.packages.direct_origin import DirectOrigin File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/packages/direct_origin.py", line 10, in <module> from poetry.inspection.info import PackageInfo File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/inspection/info.py", line 26, in <module> from poetry.utils.env import EnvCommandError File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env/__init__.py", line 10, in <module> from poetry.utils.env.env_manager import EnvManager File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env/env_manager.py", line 17, in <module> import virtualenv File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/__init__.py", line 3, in <module> from .run import cli_run, session_via_cli File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/run/__init__.py", line 11, in <module> from ..seed.wheels.periodic_update import manual_upgrade File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/__init__.py", line 3, in <module> from .acquire import get_wheel, pip_wheel_env_run File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/acquire.py", line 11, in <module> from .bundle import from_bundle File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/bundle.py", line 4, in <module> from .periodic_update import periodic_update File "$HOME/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/periodic_update.py", line 11, in <module> import ssl File "$HOME/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ImportError: dlopen($HOME/.pyenv/versions/3.10.4/lib/python3.10/lib-dynload/_ssl.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib Referenced from: [参照先情報] $HOME/.pyenv/versions/3.10.4/lib/python3.10/lib-dynload/_ssl.cpython-310-darwin.so Reason: tried: '/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib' (no such file), '/usr/local/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file, not in dyld cache)
対応
まず、ログからpyenv
では3.12.0
をインストールして、global
指定しているにも関わらず、poetry
では3.10系
で動作しているのが気になりました。
環境構築がpyenv
と連動していないようにも思えたため、pyenv
とpoetry
の仕様を確認し、poetry
を再インストールすることにしました。
python 3.10とopensslの依存関係
調べると以下のissueが見つかりました。python 3.10
ではOpenSSL >= 1.1.1
を必要としているようですが、openssl@1.1
と比較してバージョンは低いので、これがMacでは関連があるのかわかりませんでしたが、しかし、openssl@1.1
に依存いる可能性はありそうだと推測しました。
Python 3.10 OpenSSL 設定の問題 ·問題 #91019 ·python/cpython:
pyenv環境の確認
念の為、pyenv
のインストールに必要な情報を確認します。
If you haven't done so, install Xcode Command Line Tools (xcode-select --install) and Homebrew. Then:
brew install openssl readline sqlite3 xz zlib tcl-tk
上記は現状問題なくインストールされていることを確認しました。
pyenv-suggested-build-environment:
Poetryの再インストール
Poetryの公式手順を確認してアンインストール、インストールを実行します。
installing-with-the-official-installer:
<注意事項>一部環境変数に置き換えています。
% curl -sSL https://install.python-poetry.org | python3 - 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: $HOME/.local/bin You can uninstall at any time by executing this script with the --uninstall option, and these changes will be reverted. Installing Poetry (1.6.1): Done Poetry (1.6.1) is installed now. Great! To get started you need Poetry's bin directory ($HOME/.local/bin) in your `PATH` environment variable. Add `export PATH="$HOME/.local/bin:$PATH"` to your shell configuration file. Alternatively, you can call Poetry explicitly with `$HOME/.local/bin/poetry`. You can test that everything is set up by executing: `poetry --version`
インストール後以下を実行します。
~/.zprofile
にexport PATH="$HOME/.local/bin:$PATH"
を追加poetry config virtualenvs.in-project true
を実行して仮想環境下に.venv
を作成するように変更
ここで、~/.zprofile
を確認すると3.10
を指定していました。
もしかすると下記を修正して、3.10
より大きいバージョンをインストールすることでSSL(openssl@1.1)
のエラーは解消する可能性もあります。
# poetry #export PATH="$HOME/Library/Python/3.10/bin:$PATH" # 無効(コメントアウト) export PATH="$HOME/.local/bin:$PATH" # 追加
インストール後の動作確認
poetry new
コマンド:OK
% poetry new my_project Created package my_project in my_project
poetry self update
コマンド:OK
% poetry self update Updating Poetry version ... Using version ^1.6.1 for poetry Updating dependencies Resolving dependencies... Downloading https://files.pythonhosted.org/packages/41/3a/2e2e902afcd751738e38d88af976fc4010b16e8e821945f4cbf32f75f9c3/msgpack-1.0.7-cResolving dependencies... Downloading https://files.pythonhosted.org/packages/38/bd/45ac5374fde553fc9912be2f5029a8a8dc9f2d52e39a6fb6b73acba39b2b/dulwich-0.21.6-Resolving dependencies... (2.9s) No dependencies to install or update
まとめ
openssl@1.1
のアンインストールに伴う、poetry
コマンドが実行できない問題に関する現象と解決方法を紹介しました。- 前回の記事では
expect
コマンドが依存関係にあることを説明しましたが、brew
コマンドで管理していないコマンド、その他アプリについても影響確認する必要があると思います。 - 実行エラーになる場合は依存関係を確認し、対処する手間はありますが、latestであれば
openssl@3
に対応していると思うので最新のバージョンに更新することで問題が解消するか確認することが必要かと思います。
以上です。