CPAN在ubuntu上给出了各种错误

时间:2011-07-29 16:40:19

标签: linux perl ubuntu cpan

我只是想运行一个简单的perl程序从xml导入数据并将其导出到数据库。

使用Mysql;没用,所以我使用DBD :: mysql后,无法从cpan获取Mysql.pm。

但是,我无法安装任何东西。我正在尝试安装xml解析器模块,但无论您尝试安装哪个模块,cpan都会出现这些错误。

install xml::parser
CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
CPAN: Compress::Zlib loaded ok (v2.02)
............................................................................DONE
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
CPAN: Time::HiRes loaded ok (v1.9719)
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
DONE
Going to read '/root/.cpan/sources/modules/03modlist.data.gz'
Catching error: "Can't locate object method \"data\" via package \"CPAN::Modulelist\" (perhaps you forgot to load \"CPAN::Modulelist\"?) at (eval 29) line 1.\cJ at /usr/share/perl/5.10/CPAN/Index.pm line 518\cJ\cICPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl/5.10/CPAN/Index.pm line 85\cJ\cICPAN::Index::reload('CPAN::Index') called at /usr/share/perl/5.10/CPAN.pm line 955\cJ\cICPAN::exists('CPAN=HASH(0xa225610)', 'CPAN::Module', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1243\cJ\cICPAN::Shell::expandany('CPAN::Shell', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1639\cJ\cICPAN::Shell::rematein('CPAN::Shell', 'install', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1935\cJ\cICPAN::Shell::__ANON__('CPAN::Shell', 'xml::parser') called at /usr/share/perl/5.10/CPAN.pm line 375\cJ\cIeval {...} called at /usr/share/perl/5.10/CPAN.pm line 372\cJ\cICPAN::shell() called at /usr/bin/cpan line 198\cJ" at /usr/share/perl/5.10/CPAN.pm line 391
    CPAN::shell() called at /usr/bin/cpan line 198
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
cpanDONE
Going to read '/root/.cpan/sources/modules/03modlist.data.gz'
No history written (no histfile specified).
Lockfile removed.
Can't locate object method "data" via package "CPAN::Modulelist" (perhaps you forgot to load "CPAN::Modulelist"?) at (eval 31) line 1.
 at /usr/share/perl/5.10/CPAN/Index.pm line 518
    CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl/5.10/CPAN/Index.pm line 85
    CPAN::Index::reload('CPAN::Index') called at /usr/share/perl/5.10/CPAN.pm line 692
    CPAN::all_objects('CPAN=HASH(0xa225610)', 'CPAN::Distribution') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1046
    CPAN::Shell::failed('CPAN::Shell', 2, 1) called at /usr/share/perl/5.10/CPAN.pm line 413
    eval {...} called at /usr/share/perl/5.10/CPAN.pm line 413
  CPAN::shell() called at /usr/bin/cpan line 198

我做错了吗?我尝试搜索这些错误,但没有人有正确的解决方案。我应该更改配置中的某些设置吗?

6 个答案:

答案 0 :(得分:13)

如果没有人能解答您的特定问题,我可能会尝试使用新的cpan,例如:

cd && mv .cpan .cpan-bak

然后再次尝试安装模块。

希望这有帮助。

答案 1 :(得分:4)

我遇到了类似的问题。

情况:

尝试安装Catalyst :: Plugin :: AutoCRUD

使用perl版本:perlbrew-5.14.2

溶液:

问题是sudo我正在这样的cpan install命令:

DIDNT WORK:

sudo cpan Catalyst::Plugin::AutoCRUD

WORKS:

chown -R myusername:myusergroup ~/.cpan
cpan Catalyst::Plugin::AutoCRUD

原因:因为我在我的用户帐户下安装了perlbrew + cpan,而不是root用户,所有后续的cpan模块安装必须由同一用户安装。

答案 2 :(得分:2)

当我与perl网站的连接超时时,我遇到了同样的问题。 /root/.cpan/sources/modules/02packages.details.txt.gz仅包含网络超时的信息,/root/.cpan/sources/modules/03modlist.data.gz也是垃圾邮件。

只删除这些文件,并在网络不太繁忙时再次尝试,然后正确获取文件,一切正常。

答案 3 :(得分:2)

检查您的“cpan”版本(您的安装程序)是否与您的“perl”版本匹配...

通过执行以下操作来检查: cpan --version perl -v

我在尝试安装另一个模块时遇到了同样的错误,结果发现我使用的“cpan”版本是作为5.8.8 perl软件包的一部分编译的,但是“perl”的版本是在工作中设置为默认值是版本5.8.5,因此cpan使用对5.8.5 perl基础实现时不兼容的错误的5.8.8 perl基本库的引用来编译C代码。

简单的解决方案是使用完整路径“ / usr /.../ perl / 5.8.5 / bin / cpan module_name ”调用正确的“cpan”程序。

将不同版本软件包的不同二进制文件作为默认值的这种小不一致是我们的管理员的疏忽,并且确实引起了很多悲痛。

答案 4 :(得分:1)

要解决此问题,我必须在Centos7上安装cpanm。

步骤:

yum install perl-devel
yum install perl-CPAN
curl -L http://cpanmin.us | perl - --sudo App::cpanminus

使用以下方式将本地垃圾箱(/usr/local/bin)添加到PATH

PATH=$PATH:/usr/local/bin

链接

答案 5 :(得分:0)

在我的情况下,我需要使用sudo -H运行cpan来获取本地网络设置(例如代理)。所以:     cd && mv .cpan .cpan-bak

然后:     须藤-H cpan

默认回答cpan配置(这次错误没有出现)。

然后我可以安装任何模块。