最近在把两个版本的PDL Book(2012年2月版、2015年5月版)的电子书(.pdf格式)转化为可在IPerl内核的Jupyter Notebook中进行交互学习的电子书(.ipynb格式)。在制作基于2012年2月版第二章内容的.ipynb文件时,示例中的use PDL::Graphics::TriD代码居然不工作,并反馈错误信息:
Can't load '/usr/lib/x86_64-linux-gnu/perl5/5.36/auto/PDL/Graphics/OpenGLQ/OpenGLQ.so' for module PDL::Graphics::OpenGLQ: libglut.so.3: 无法打开共享对象文件: 没有那个文件或目录 at /usr/lib/x86_64-linux-gnu/perl-base/DynaLoader.pm line 201.
at /usr/lib/x86_64-linux-gnu/perl5/5.36/PDL/Graphics/TriD/GL.pm line 782.
Compilation failed in require at /usr/lib/x86_64-linux-gnu/perl5/5.36/PDL/Graphics/TriD/GL.pm line 782.
BEGIN failed--compilation aborted at /usr/lib/x86_64-linux-gnu/perl5/5.36/PDL/Graphics/TriD/GL.pm line 782.
Compilation failed in require at /usr/lib/x86_64-linux-gnu/perl5/5.36/PDL/Graphics/TriD.pm line 733.
BEGIN failed--compilation aborted at /usr/lib/x86_64-linux-gnu/perl5/5.36/PDL/Graphics/TriD.pm line 736.
Compilation failed in require at (eval 34) line 4.
BEGIN failed--compilation aborted
相应模块都安装了的呀。在PDL Shell中测试,也是如此。而且在PDL Shell中按demo命令的结果是:
pdl> demo
Use:
demo pdl # general demo
demo bad # Bad-value demo (Optional: PGPLOT)
demo cartography # Cartographic projections (Req.: PGPLOT)
demo gnuplot # Gnuplot graphics
demo pgplot # PGPLOT graphics output
demo pgplotOO # PGPLOT OO interface
demo sound # Sound (requires a sound player)
demo transform # Coordinate transformations (Req.: PGPLOT)
Attempt to reload PDL/Demos/TriD1.pm aborted.
Compilation failed in require
几个与TriD.pm相关的demo居然都没有了。仔细阅读反馈的错误信息,就是没有libglut.so.3文件。sudo find / -name libglut.so*发现有:
/usr/lib/x86_64-linux-gnu/libglut.so
/usr/lib/x86_64-linux-gnu/libglut.so.3.12.0
/usr/lib/x86_64-linux-gnu/libglut.so.3.12
再仔细一捋,发现libglut.so、libglut.so.3.12都是指向libglut.so.3.12.0的软链接。就缺libglut.so.3。于是用sudo ln -s /usr/lib/x86_64-linux-gnu/libglut.so.3.12.0 /usr/lib/x86_64-linux-gnu/libglut.so.3创建了libglut.so.3。再次进入PDL shell中运行demo,结果就比上面的结果多了以下三个演示示例:
demo 3d # 3d demo (requires TriD with OpenGL or Mesa)
demo 3d2 # 3d demo, part 2. (Somewhat memory-intensive)
demo 3dgal # the 3D gallery: make cool images with 3-line scripts
运行示例都能正常工作。运行use PDL::Graphics::TriD,也没有问题了。