开始学习machine learning,Andre Ng推荐使用Octave,按照课程介绍下载安装后无法画图,
报错为dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib
于是google搜了一圈,也试了不少,最终经过近2个小时的折腾,终于搞定,步骤如下。
1 把xcode update到最新(其实这步可做可不做,做了后多了不少麻烦,但是考虑到以后如果一更新就要重新来过,还是更了)
2 运行homebrew
$ brew cleanup
$ brew update
此时运行$ brew install octave 如果没报错就继续安装gnuplot,但是我这报错频频,首先是Error: No available formula for octave
3 换种方式安装
$ brew install https://raw.github.com/Homebrew/homebrew-science/master/octave.rb
若没错,此时就正常安装了。
但对我来说,这才刚刚开始,此时显示 Error: No available formula for suite-sparse,继续
$ brew install https://raw.github.com/Homebrew/homebrew-science/9c476a291adb0739b8f34be0ac5910f49abcaed5/suite-sparse.rb
同时把一些相关的都装了glpk,qhull
$ brew install https://raw.github.com/Homebrew/homebrew-science/master/glpk.rb
$ brew install https://raw.github.com/Homebrew/homebrew-science/master/qhull.rb
这时再运行
$ brew install https://raw.github.com/Homebrew/homebrew-science/master/octave.rb
安装终于开始了。。。
安装结束后在terminal里输入octave,就可以进行基本的运算了,此时画图还不行。若尝试下
octave:1> x = linspace(-10, 10, 100);
octave:2> y = sin(x);
octave:3> plot(x,y);
应该会显示
warning: broken pipe -- some output may be lost
warning: broken pipe -- some output may be lost
warning: broken pipe -- some output may be lost
warning: broken pipe -- some output may be lost
warning: broken pipe -- some output may be lost
control+d 退出octave,安装gnuplot
$ brew install gnuplot
此时再进入octave,继续尝试刚才的画图命令,应该会显示
gnuplot> set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6"
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list
此时只需要在plot这个command前输入setenv("GNUTERM", "X11")这条命令即可。
Tada,终于搞定了。(记得装好X11哦)。
希望对mac上安装octave的同学有帮助。