我相信 python 中的 pickle 模块未发现 Heroku 应用程序模块错误

Heroku app module not found error with pickle module in python I believe

该应用程序在本地运行良好,但当推送到 heroku 时,我收到一个围绕我的 pickle 加载的模块未找到错误。我试图将缺少的模块添加到 requirements.txt 但收到更多错误。以下是错误信息:

ModuleNotFoundError: No module named 'numba.serialize'
Traceback:
File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/script_runner.py", line 324, in _run_script
    exec(code, module.__dict__)
File "/app/app.py", line 49, in <module>
    UMAP = pickle.load((open('data/UMAPwrv.sav', 'rb')))

有谁知道如何解决这个问题?谢谢!

我建议您开始使用 venv 来管理 Python 包。你可以了解更多here.

但是,正如文档明确指出的那样:

These are the lowest-level tools for managing Python packages and are recommended if higher-level tools do not suit your needs.

所以,我个人的建议是使用 Pipfile