Cannot installing mechanize for ruby on mac

2019-07-23 16:55发布

问题:

I am trying to install mechanize on a Mac OS X Version 10.7.3 with ruby version 1.8.7. The problem is with one of its dependencies nokogiri. I have seen other posts about having xcode installe and I do it is version 4.3.2 . Here is the error I am receiving. Thank you in advance.

sudo gem install mechanize
Building native extensions.  This could take a while...
ERROR:  Error installing mechanize:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.2 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.2/ext/nokogiri/gem_make.out

回答1:

I needed to simply install the command line tools for xcode and it went smooth. The nokogiri gem has to be compiled.



回答2:

what about this:

pip install mechanize

or

easy_install mechanize