Lua 加载模块时出错 'libpng'(Torch、MacOSX)
Lua error loading module 'libpng' (Torch, MacOSX)
如何在 Lua 中正确加载 libpng?我在 运行ning Lua/Torch in Mac OSX 10.10.3 的 iTorch Notebook 中, Lua 中的其他基本功能在这里工作,例如绘图和计算。
brew install libpng
Warning: libpng-1.6.17 already installed
如果我运行:
require 'nn';
require 'image';
itorch.image(image.lena())
error loading module 'libpng' from file '/usr/local/lib/lua/5.1/libpng.so':
dlopen(/usr/local/lib/lua/5.1/libpng.so, 6): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/lib/lua/5.1/libpng.so
Reason: Incompatible library version: libpng.so requires version 33.0.0 or later, but libpng15.15.dylib provides version 29.0.0
warning: could not be loaded (is it installed?)
/usr/local/share/lua/5.1/dok/inline.lua:736: libpng package not found, please install libpng
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/dok/inline.lua:736: in function 'error'
/usr/local/share/lua/5.1/image/init.lua:142: in function 'saver'
/usr/local/share/lua/5.1/image/init.lua:355: in function 'save'
/Users/MY/torch/install/share/lua/5.1/itorch/gfx.lua:25: in function 'f'
[string "local f = function() return itorch.image(iii)..."]:1: in main chunk
[C]: in function 'xpcall'
/Users/MY/torch/install/share/lua/5.1/itorch/main.lua:177: in function
/Users/MY/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll'
/Users/MY/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll'
/Users/MY/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex'
/Users/MY/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start'
/Users/MY/torch/install/share/lua/5.1/itorch/main.lua:344: in main chunk
[C]: in function 'require'
[string "arg={'/Users/MY/.ipython/profile_default/secu..."]:1: in main chunk
重新安装图像包以及强制链接 libpng 可能会解决它:
brew link libpng --force
luarocks install image
我遇到了类似的问题 (OSX 10.9.5)。您可能安装了多个版本的 libpng,在安装 luarocks 期间调用的版本具有 i386 架构(需要x86_64)。
解决这个问题:
再次尝试安装映像,并阅读日志:
luarocks 安装镜像
检查日志以查看是否收到以下类型的消息:
ld:警告:忽略文件 /Library/Frameworks//libpng.framework/libpng,在文件 /Library/Frameworks//libpng.framework/libpng 中缺少必需的体系结构 x86_64 (2 片)
如果是这种情况(假设使用 brew)删除 /Library/Frameworks 中的 libpng 框架并执行
brew 安装 libpng --universal
重新安装映像和运行。
这对我有用,希望对你也有用。
如何在 Lua 中正确加载 libpng?我在 运行ning Lua/Torch in Mac OSX 10.10.3 的 iTorch Notebook 中, Lua 中的其他基本功能在这里工作,例如绘图和计算。
brew install libpng
Warning: libpng-1.6.17 already installed
如果我运行:
require 'nn';
require 'image';
itorch.image(image.lena())
error loading module 'libpng' from file '/usr/local/lib/lua/5.1/libpng.so': dlopen(/usr/local/lib/lua/5.1/libpng.so, 6): Library not loaded: /usr/local/lib/libpng15.15.dylib Referenced from: /usr/local/lib/lua/5.1/libpng.so Reason: Incompatible library version: libpng.so requires version 33.0.0 or later, but libpng15.15.dylib provides version 29.0.0 warning: could not be loaded (is it installed?) /usr/local/share/lua/5.1/dok/inline.lua:736: libpng package not found, please install libpng stack traceback: [C]: in function 'error' /usr/local/share/lua/5.1/dok/inline.lua:736: in function 'error' /usr/local/share/lua/5.1/image/init.lua:142: in function 'saver' /usr/local/share/lua/5.1/image/init.lua:355: in function 'save' /Users/MY/torch/install/share/lua/5.1/itorch/gfx.lua:25: in function 'f' [string "local f = function() return itorch.image(iii)..."]:1: in main chunk [C]: in function 'xpcall' /Users/MY/torch/install/share/lua/5.1/itorch/main.lua:177: in function /Users/MY/torch/install/share/lua/5.1/lzmq/poller.lua:75: in function 'poll' /Users/MY/torch/install/share/lua/5.1/lzmq/impl/loop.lua:307: in function 'poll' /Users/MY/torch/install/share/lua/5.1/lzmq/impl/loop.lua:325: in function 'sleep_ex' /Users/MY/torch/install/share/lua/5.1/lzmq/impl/loop.lua:370: in function 'start' /Users/MY/torch/install/share/lua/5.1/itorch/main.lua:344: in main chunk [C]: in function 'require' [string "arg={'/Users/MY/.ipython/profile_default/secu..."]:1: in main chunk
重新安装图像包以及强制链接 libpng 可能会解决它:
brew link libpng --force
luarocks install image
我遇到了类似的问题 (OSX 10.9.5)。您可能安装了多个版本的 libpng,在安装 luarocks 期间调用的版本具有 i386 架构(需要x86_64)。
解决这个问题:
再次尝试安装映像,并阅读日志:
luarocks 安装镜像
检查日志以查看是否收到以下类型的消息:
ld:警告:忽略文件 /Library/Frameworks//libpng.framework/libpng,在文件 /Library/Frameworks//libpng.framework/libpng 中缺少必需的体系结构 x86_64 (2 片)
如果是这种情况(假设使用 brew)删除 /Library/Frameworks 中的 libpng 框架并执行
brew 安装 libpng --universal
重新安装映像和运行。
这对我有用,希望对你也有用。