我在GitHub上有一个Jupyter笔记本,想在Binder中运行它,以便其他人可以玩它。
然而,它抱怨没有安装熊猫。 错误是:
ModuleNotFoundError: No module named 'pandas'
如何让 Binder 为此实例安装熊猫?
您必须在存储库的底部编辑/创建requirements.txt
。我尝试在单元格中使用 pip 安装方法,但这不适用于 Binder,因为它会阻止会话中的实时安装。
您可以列出所需的模块,并根据需要指定版本。
这个 GitHub 中有一个例子:
- https://github.com/binder-examples/requirements/blob/master/requirements.txt
内容是:
numpy==1.16.*
matplotlib==3.*
seaborn==0.8.1
pandas
值得一提的是,requirements.txt
文件必须在 GitHub 存储库中创建,而不是在 Binder UI 中创建。Binder UI 也是只读的,不会将任何文件同步回 GitHub。不会选取 Binder UI 中的任何requirements.txt
,如果重新加载运行时或刷新页面,也不会考虑它。创建requirements.txt
后,再次启动指向 GitHub 存储库的 Binder UI 起始页。