Require 'RMagick' not working?

本小妞迷上赌 提交于 2019-12-24 12:12:30

问题


I have installed RMagick on OSX via MacPorts and can see it by running 'gem server'. However when I try to include it in my script using

require 'rubygems'
require 'RMagick'

It crashes with the following error message

./RMagick.rb:4:in `show_info': uninitialized constant Magick (NameError)
    from ./RMagick.rb:24
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from ./rmagick.rb:1
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from get_pixels.rb:2

Could anyone tell me what I'm doing wrong?


回答1:


I have once created an ImageResize Tool and I just checked how I've included it there:

require 'rubygems'
require 'RMagick'
include Magick

I have also OS X and installed the RMagick with macports. Maybe you need also to include the Module Magick. But I'm not sure.

Some more code from your RMagick.rb would maybe help to detect the problem..



来源:https://stackoverflow.com/questions/2662977/require-rmagick-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!