Help us understand the problem. What is going on with this article?

jupyter(ipython notebook) + matplotlib + vagrantでグラフ描画

More than 1 year has passed since last update.

環境

  • Python 3.5.2
  • matplotlib 1.5.3
  • ipython 5.1.0
  • jupyter 4.2.0
  • vagrant
  • CentOS7.1

関連記事

python(pyenv)インストールメモ

Jupyter LabをDockerで環境構築する

Vagrantで環境構築する場合

install matplotlib

$ pip install matplotlib

install jupyter

$ pip install jupyter

vagrant sshでポートフォワーディング設定

PCのブラウザから、vagrant上のjupyterにアクセスするためポートフォワーディングさせる。

$ vagrant ssh -- -L 8888:localhost:8888

それか、Vagrantfileに以下を追記

Vagrantfile
Vagrant.configure("2") do |config|
  # *snip*
  config.vm.network "forwarded_port", guest: 8888, host: 8888
  # *snip*
end

jupyterを起動

--ip=0.0.0.0 はlocalhost以外でのアクセスをする場合に必要。

$ jupyter notebook --no-browser --ip=0.0.0.0

もしくは

$ ipython notebook --no-browser --ip=0.0.0.0

ブラウザからjupyter-notebookへアクセス

http://localhost:8888
もしくはvagrantのIPアドレスでアクセス
http://192.168.33.10:8888

右上のプルダウンメニューを下記のようにたどっていく
New -> Python 3
581d5c.png
sample codeを実行

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(-3, 3, 0.1)
y = np.sin(x)
plt.plot(x, y)

9bd360.png

No module named _tkinterとかtkinter関連のエラーが出る場合はこちらを参照
matplotlib使うなら下記も先にインストール

以上

[参考]
vagrant で ipython notebook 環境を構築した話
vagrantで作ったVMでipython notebookを立ち上げてローカルからアクセスする
jupyter (ipython) notebook でグラフが出ない時の対応方法

Esfahan
WEB系出身。現在はビッグデータの基盤構築、ETLなどがメイン。 / YouTubeで料理チャンネルやってます → https://www.youtube.com/channel/UCDnYBh2TtUAfQ0Z-tl0jTyw
https://www.youtube.com/channel/UCDnYBh2TtUAfQ0Z-tl0jTyw
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした