Binder - HelloWorld

Binder能做什么?

Binder提供代码以及执行它的硬件和软件的服务。

创建仓库
  • GitHub创建仓库"my-first-binder"

    • 确定仓库是public
    • 不要忘记初始化README
  • 通过Web界面创建一个名为hello.py的文件,添加内容print(“ Hello from Binder!”)并提交给master分支

在这里插入图片描述

使用Binder启动仓库
  • 打开 https://mybinder.org
  • 在"GitHub repo or URL" 输入框中,键入新建仓库地址:https://github.com/wblong/my-first-binder.git
  • 单击“Launch”按钮,等待环境创建成功后,浏览器会自动弹出Jupyter Notebook界面
    在这里插入图片描述
运行 hello.py
  • Jupyter Notebook右上角,单击"New" -> “Terminal”
  • 在新Tab页面的终端中键入python hello.py,并回车

终端会执行脚本,打印Hello from Binder!
在这里插入图片描述

添加依赖
  • 代码仓库新建requirements.txt
  • 添加 numpy==1.14.5
  • 提交代码
  • 重新启动“Launch”,并查看" Build Logs"
检查环境
  • Jupyter Notebook右上角,单击"New" -> “Python3” 打开notebook
  • 新建一个Cell,键入:
import numpy
print(numpy.__version__)
numpy.random.randn()
  • 运行

在这里插入图片描述

共享

直接分享链接
https://mybinder.org/v2/gh/wblong/pvgeo-binder.git/master
在这里插入图片描述

共享数据

下载dropbox链接的数据。
在这里插入图片描述

import urllib.request
link = 'https://dl.dropbox.com/s/gw5v3tiq68oge3l/Example-Extract-Topo.zip?dl=0'
f=urllib.request.urlopen(link)
with open("topo.vtk", "wb") as code:
    code.write(f.read())
print("test")

在这里插入图片描述

Referece

https://github.com/alan-turing-institute/the-turing-way/blob/master/workshops/boost-research-reproducibility-binder/workshop-presentations/zero-to-binder-python.md#1-creating-a-repo-to-binderize

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值