LoginSignup
0
0

More than 1 year has passed since last update.

[Streamlit Cloud] デプロイ時にパッケージinstallできないバグ

Posted at

streamlitを最近知ったのですが手軽にデータ処理をしてそのままUIに乗っけたいときに重宝しています。

今回はstreamlitで作ったアプリを公開したく Streamlit Cloudにデプロイしようとしたときにパッケージがinstallできないバグに遭遇したのでその解決法です。
*パッケージ管理はanacondaを使用していました。

環境
conda 4.11.0
python 3.9

解決法

先に結論を言うとconda経由のinstallは諦めてpipに変えました。
pip list --format=freeze > requirements.txt

何をしたか

conda list -e > requirements.txt

一番最初は上記のコマンドで作成したrequirements.txtをあげていました。

これはconda用の環境のようです。streamlit cloudではrequirements.txtはpipでinstallするのでエラーが起きてしまいました

エラー内容

ERROR: Invalid requirement: '_ipyw_jlab_nb_ext_conf=0.1.0=py38_0' (from line 4 of /app/chem_app/requirements.txt)

Hint: = is not a valid operator. Did you mean == ?

conda env export > environment.yml

condaでinstallしたい場合はenvironment.ymlで出力すれば良いとのこと。

packageの解決ができず断念。

エラー内容

Collecting package metadata (repodata.json): ...working... [日付] done
Solving environment: ...working... [日付] failed

pip freeze > requirements.txt

condaで一通り触って無理だったので潔く諦めました。
*conda経由のinstallでエラーが出るissueも散見できます。

pipで依存パッケージを入れた後にrequirements.txtに出力してあげました。
installで普通にエラー。
requirements.txtを確認するとバージョンを出力してほしいところに@fileみたいな記述が、、
https://teratail.com/questions/272968

pip list --format=freeze > requirements.txt

先ほどのteratailで触れてある通りformatを指定してみます。
requirements.txtから@fileが削除され無事versionが出力されました。

installまでは成功したのですが謎のエラーに苦しめられ起動できない。もう一歩

エラー内容

ResolvePackageNotFound: 
 × Building wheel for pycairo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/cairo
      copying cairo/__init__.py -> build/lib.linux-x86_64-cpython-39/cairo
      copying cairo/__init__.pyi -> build/lib.linux-x86_64-cpython-39/cairo
      copying cairo/py.typed -> build/lib.linux-x86_64-cpython-39/cairo
      running build_ext
      'pkg-config' not found.
      Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycairo

pip list --format=freeze > requirements.txt

潔くconda環境を作り直し、全てpip経由で入れました。

無事動いた

[] 🐍 Python dependencies were installed from /app/[app]/requirements.txt using pip.
[] 📦 Processed dependencies!
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0