不断收到错误"Can't locate Image/Grab.pm in @INC"安装 Perl mod 后 [英] Keep getting error "Can't locate Image/Grab.pm in @INC" after installing the Perl mod

查看:45
本文介绍了不断收到错误"Can't locate Image/Grab.pm in @INC"安装 Perl mod 后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程有点陌生,我在编写 Perl 脚本时遇到了一些问题,该脚本将从网页中获取所有图像并将它们保存在指定目录中.

I'm a bit new to programming and I'm having some trouble writing a Perl script that will grab all the images from a webpage and save them in a specified directory.

这是我的代码:

use warnings;
use strict;
use lib '/home/User1/strawberry/cpan/build';
use Image::Grab;

$pic = Image::Grab->new(SEARCH_URL=>'http://www.examplesite.com',
                          REGEXP    =>'.*\.gif|.*\.jpg');
my $dir = 'images';

opendir (IMG, ">>$dir") || die "Directory doesn't exist - $!\n";
foreach ($pic) {
        print IMG "$_\n";
}
closedir IMG;

这是我在 PuTTY 中运行脚本时得到的错误:

This is the error I get when I run the script in PuTTY:

在@INC 中找不到 Image/Grab.pm(@INC 包含:/home/User1/strawberry/cpan/build/etc/perl/usr/local/lib/perl/5.10.1/usr/local/share/perl/5.10.1/usr/lib/perl5/usr/share/perl5/usr/lib/perl/5.10/usr/share/perl/5.10/usr/local/lib/site_perl .) 在getimage.pl 第 7 行 BEGIN 失败--编译在 getimage.pl 中止第 7 行.

Can't locate Image/Grab.pm in @INC (@INC contains: /home/User1/strawberry/cpan/build /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at getimage.pl line 7. BEGIN failed--compilation aborted at getimage.pl line 7.

感谢您的帮助

推荐答案

当你没有安装模块时,这是一个标准错误.Image::Grab 不附带 perl.在名为 cpan 的东西上有很多可用的 perl 模块,例如:

That's a standard error when you haven't installed the module. Image::Grab does not come with perl. There are lots of perl modules available on something called cpan, for instance:

http://search.cpan.org/~mahex/Image-Grab-1.4.2/lib/Image/Grab.pod.

模块是某人用 perl 编写并可供您使用的函数库.

Modules are libraries of functions that someone has written in perl and made available for your use.

现在,您必须弄清楚如何安装模块.看看这是否有效:

Now, you have to figure out how to install modules. See if this works:

$ perl -MCPAN -e shell

-M => Use the module specified, in this case CPAN(comes with perl)  
-e => execute the following perl code, in this case the function shell().

然后

cpan> install Image::Grab.  

第一次这样做时,您必须回答很多问题.

The first time you do that, you'll have to answer a lot of questions.

完成后:

cpan> q  ('q' is for quit)

回复评论:

1) 尝试更新您的 CPAN 模块:

1) Try updating your CPAN module:

cpan> install CPAN
cpan> reload cpan

然后:

cpan> install Image::Grab

从源代码安装很好,但是如果您可以让 cpan 工作,那么它会负责下载所有依赖项,因此它很容易.我只是用 cpan 下载 Image::Grab,我没有出错.它没有需要下载的依赖项.

Installing from source is fine, but if you can get cpan to work, then it takes care of downloading all the dependencies, so it is hassle free. I just used cpan to download Image::Grab, and I got no errors. It has no dependencies that need to be downloaded.

2) 输出是什么:

$ perl --version (it looks like you are using perl 5.10.1)  

此外,在您的问题底部添加您的 cpan 尝试的整个输出.

Also, at the bottom of your question add the entire output from your cpan attempt.

3) 尝试安装另一个模块,例如:

3) Try installing another module, like:

http://search.cpan.org/~rehsack/List-MoreUtils-0.402/lib/List/MoreUtils.pm

这篇关于不断收到错误"Can't locate Image/Grab.pm in @INC"安装 Perl mod 后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆