Mac 上Octave gnuplot安装

开始学习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的同学有帮助。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值