LoginSignup
7
6

More than 5 years have passed since last update.

Vagrant上のUbuntuにScipy+Matplotlibを入れてX11 Forwardingでグラフを表示する

Last updated at Posted at 2014-11-20

環境

  • ホストOS : Mac OSX Yosemite
  • ゲストOS : Ubuntu 14.04.1 LTS

手順

XQuartzをインストール

Macにこれをインストール
http://xquartz.macosforge.org/landing/

Vagrantfile編集

Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.forward_x11 = true    # これを追加
end

UbuntuにX11, Matplotlib, NumPy, SciPy, IPythonをインストール

$ vagrant up
$ vagrant ssh
vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get update
vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get install -y xorg python-matplotlib python-numpy python-scipy ipython

Ubuntuを再起動してグラフ表示

$ vagrant reload
$ vagrant ssh
vagrant@vagrant-ubuntu-trusty-64:~$ ipython --pylab
In [1]: import matplotlib.pyplot as plot
In [2]: import scipy as sp
In [3]: x = sp.arange(1,100)
In [4]: plot.scatter(x, x**2)

Screen Shot 2014-11-20 at 8.37.51 PM.png

X11 Forwardingがうまくいかないとき

vagrant sshしたときに

/home/vagrant/.Xauthority not writable, changes will be ignored

と出たら、~/.Xauthority*を削除してログインし直してみてください。

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6