
そうするとJupyter Notebook形式でコードが表示されます。

このプログラムをこのままオンライン上で実行するには、ページ右上の「Execute on Binder」(以下の赤丸のアイコン)をクリック。

そうすると、Binderに移行し実行可能な環境ができあがり、オンライン上でJupyter Notebookが使用可能。

必要なモジュール/requirements.txt:
しかし、このプログラムに必要なモジュール(numpy、matplotlibなど)がこの環境にインストールされていなければエラーがでます。必要なモジュールについては、ipynbファイルとは別にrequirements.txtがアップロードされており、その中に記述されています。

Binder内のディレクトリ。

requirements.txtを開くと必要なモジュール名が書いてあります。requirements.txtがipynbファイルと同じディレクトリ内にあれば自動でモジュールがインストールされますが、もしrequirements.txtがなければ自力で必要そうなモジュールをインストールする必要があります。
ターミナルでモジュールをインストール:

ディレクトリのページに戻り、右上の「New」から「Terminal」を選択。
ターミナル 画面が現れたら、pipなどで必要なモジュールをこの環境にインストール。

必要なモジュールが揃えば、プログラム実行可能なります。
直接「Binder」にアクセスして実行:
また、nbviewerを使わずに、直接「Binder」から実行するには、

Binderのトップページ。

プルダウンメニューからipynbファイルの場所の種類(GitHubやGistなど)を選択。ipynbファイルのURLを入力し「launch」ボタンをクリックでファイルが開きます。
requirements.txtがない場合はモジュールが自動インストールされないため、そのままプログラムを実行するとエラーがでるので、先ほど同様オンライン上のターミナルで自力で必要なモジュールをインストール。
池内 孝啓 片柳 薫子 岩尾 エマ はるか @driller
技術評論社
売り上げランキング: 37,985
技術評論社
売り上げランキング: 37,985
0 件のコメント:
コメントを投稿