Python pipの依存関係を解決した記録

解決の記録1: 不要なパッケージのアンインストール

エラーの現象

Cloud Functionsを利用中に以下のエラーに出くわしました。

ERROR: Cannot install -r requirements.txt (line 138) and protobuf==4.21.6 
because these package versions have conflicting dependencies. 
The conflict is caused by: The user requested protobuf==4.21.6 
tensorboard 2.10.0 depends on protobuf<3.20 and >=3.9.2 
To fix this you could try to: 
1. loosen the range of package versions you've specified 
2. remove package versions to allow pip attempt to solve the dependency conflict 
ERROR: ResolutionImpossible

原因

パッケージのprotobufとtensorboardの間で依存関係のエラーが発生しているようでした。
protobufのバージョンは3.20.1でインストールしてみたのですが、別のパッケージとの依存関係で問題となってしまいprotobufのバージョンアップでは対処できませんでした。

解決方法

色々試行錯誤した状態でrequirements.txtを作成していたため、一旦tensorboardをアンインストールしてみました。

pip uninstall tensorboard

現在のスクリプトではtensorboardを利用していなかったようで、問題なく動くようになりました!

解決した記録2: パッケージのダウングレード

エラーの現象

Cloud Functionsを利用中に以下のエラーに出くわしました。

found incompatible dependencies: 
"functions-framework 3.0.0 has requirement watchdog<2.0.0,>=1.0.0, but you have watchdog 2.1.9.

原因

パッケージのfunctions-frameworkとwatchdogの間で依存関係のエラーが発生しているようでした。

解決方法

エラーメッセージで言われている通り、watchdogのバージョンを指定してダウングレードしてみます。。

pip install watchdog==1.0.0

エラーは無事解消されました!

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA