铁路演员的问题第 190 集

发布于 2024-09-03 06:00:27 字数 1645 浏览 11 评论 0原文

听完 Rails Cast No 190 后,我坐下来尝试一下,

所以我

gem install nokogiri

在我的 Windows 7 Ultimate 笔记本电脑上安装了 nokogiri。我使用 Ruby 1.9

安装 Nokogiri Now 的方式

C:\Ruby>gem install nokogiri
Successfully installed nokogiri-1.4.2-x86-mingw32
1 gem installed
Installing ri documentation for nokogiri-1.4.2-x86-mingw32...
Updating class cache with 1221 classes...
Installing RDoc documentation for nokogiri-1.4.2-x86-mingw32...

,这就是我为以下代码

require 'rubygems'  
require 'nokogiri'  
require 'open-uri'  

url = "http://timesofindia.indiatimes.com/rssfeeds/-2128838597.cms"  
doc = Nokogiri::HTML(open(url))  
puts doc.at_css("title").text 

hello.rb我尝试以标题的形式获得结果,但出现以下错误!

C:\Ruby>ruby hello.rb
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/nokogir
i.rb:1:in `require': 127: The specified procedure could not be found.   - Init_n
okogiri (LoadError)
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/1.9/nok
ogiri.so
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri/nokogiri.rb:1:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `<top (required)>'
        from hello.rb:2:in `require'
        from hello.rb:2:in `<main>'

我尝试使用 gem uninstall nokogiri 卸载并重新安装,但仍然无法摆脱该错误。

请帮我解决它!

谢谢

高塔姆

After listening to Rails Cast No 190 I sat down to try it

So I installed nokogiri with

gem install nokogiri

on my Windows 7 Ultimate laptop. I use Ruby 1.9

and this is the way i Installed Nokogiri

C:\Ruby>gem install nokogiri
Successfully installed nokogiri-1.4.2-x86-mingw32
1 gem installed
Installing ri documentation for nokogiri-1.4.2-x86-mingw32...
Updating class cache with 1221 classes...
Installing RDoc documentation for nokogiri-1.4.2-x86-mingw32...

Now for the following code hello.rb

require 'rubygems'  
require 'nokogiri'  
require 'open-uri'  

url = "http://timesofindia.indiatimes.com/rssfeeds/-2128838597.cms"  
doc = Nokogiri::HTML(open(url))  
puts doc.at_css("title").text 

I tried to get a result in the form of Title but I am getting the following error!!

C:\Ruby>ruby hello.rb
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/nokogir
i.rb:1:in `require': 127: The specified procedure could not be found.   - Init_n
okogiri (LoadError)
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/1.9/nok
ogiri.so
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri/nokogiri.rb:1:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `<top (required)>'
        from hello.rb:2:in `require'
        from hello.rb:2:in `<main>'

I have tried to uninstall and reinstall with gem uninstall nokogiri but still i cant get rid of the error.

Please help me to fix it!!

Thanks

Gautam

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走过海棠暮 2024-09-10 06:00:27

这似乎是 Ruby 1.9.1 的已知问题。使用 Ruby 1.8.7 再次尝试以缩小问题范围。

This appears to be a known issue with Ruby 1.9.1. Try it again with Ruby 1.8.7 to narrow down your problem.

痴梦一场 2024-09-10 06:00:27

当您安装Nokogiri时,您是否遇到以下问题,您选择了什么选项?

 C:\Documents and Settings\Username>gem install nokogiri
 Bulk updating Gem source index for: http://gems.rubyforge.org
 Select which gem to install for your platform (i386-mswin32)
  1. nokogiri 1.0.6 (ruby)
  2. nokogiri 1.0.6 (x86-mswin32-60)
  3. nokogiri 1.0.5 (x86-mswin32-60)
  4. nokogiri 1.0.5 (ruby)
  5. Skip this gem
  6. Cancel installation
 >

您应该选择 x86-mswin32-60 版本。您似乎安装了非 Windows 版本。

如果您选择了 ruby​​ 选项之一,请尝试 gem uninstall nokogiri 然后再次安装

When you installed Nokogiri did you get the following question, and what option did you choose?

 C:\Documents and Settings\Username>gem install nokogiri
 Bulk updating Gem source index for: http://gems.rubyforge.org
 Select which gem to install for your platform (i386-mswin32)
  1. nokogiri 1.0.6 (ruby)
  2. nokogiri 1.0.6 (x86-mswin32-60)
  3. nokogiri 1.0.5 (x86-mswin32-60)
  4. nokogiri 1.0.5 (ruby)
  5. Skip this gem
  6. Cancel installation
 >

You should have chosen the x86-mswin32-60 version. It looks like you have a non-windows version installed.

If you chose one of the ruby options then try gem uninstall nokogiri and then install again

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文