【问题标题】:minGW and cpan modulesminGW 和 cpan 模块
【发布时间】:2011-10-03 03:26:30
【问题描述】:

我正在尝试使用 perl(ActiveState perl) 中的 Finance::TickerSymbols 模块,由于 PPM 没有它,我在我的 minGW 控制台上运行 cpan 来安装它。 安装很顺利,但是,minGW 似乎将模块安装在

C:\MinGW\msys\1.0\home\ar\.cpan\build\Finance-TickerSymbols-1.03\lib\Finance\

所以,当我运行我的 perl 代码时,我收到以下错误:

Can't locate Finance/TickerSymbols.pm in @INC(@INC contains C:/Perl64/site/lib C:/Perl64/lib .)

当然编译失败了。 我可以从 mingw 路径复制和粘贴 .pm,但这并不适用于所有情况。谁能建议如何解决这个问题。谢谢!

编辑:为其他模块运行 install 以在 minGW 中提供 install 的输出

Running install for module Finance::Curency::Convert
    Running make for J/JA/JANW/Finance-Currency-Convert-1.08.tgz
    CPAN: LWP::UserAgent loaded ok
    Fetching with LWP:
    ftp://ftp.perl.org/pub/CPAN/authors/id/J/JA/JANW/CHECKSUMS
    CPAN: Compress::Zlib loaded ok
    Checksum for /home/ar/.cpan/sources/authors/id/J/JA/JANW/Finance-Currency-Convert-1.08.tgz ok
    Scanning cache /home/ar/.cpan/build for sizes
    Deleting from cache: /home/ar/.cpan/build/GD-2.46 <24.0>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/Finance-TickerSymbols-1.03 <23.5>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/GDTextUtil-0.86 <23.4>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/GDGraph-1.44 <23.2>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/Date-Simple-3.03 <22.6>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/HTML-TableExtract-2.11 <22.4>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/Text-CSV-1.21 <22.2>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/ExtUtils-MakeMaker-6.59 <21.9>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/YAML-Syck-1.17 <19.1>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/Test-Inter-1.03 <18.2>10.0 MB>
    Deleting from cache: /home/ar/.cpan/build/Date-Manip-6.25 <18.0>10.0 MB>
    Finance-Currency-Convert-1.08/
    Finance-Currency-Convert-1.08/MANIFEST
    Finance-Currency-Convert-1.08/t/
    Finance-Currency-Convert-1.08/t/convert.t
    Finance-Currency-Convert-1.08/Makefile.PL
    Finance-Currency-Convert-1.08/Changes
    Finance-Currency-Convert-1.08/META.yml
    Finance-Currency-Convert-1.08/Convert.pm
    CPAN.pm: Going to build J/JA/JANW/Finance-Currency-Convert-1.08.tgz
    Checking if your kit is complete...
    Looks good
    Writing Makefile for Finance::Currency::Convert
    cp Convert.pm blib/lib/Finance/Currency/Convert.pm
    Autosplitting blib/lib/Finance/Currency/Convert.pm (blib/lib/auto/Finance/Currency/Convert)
    /bin/make -- OK
    Running make test
    /usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib','blib/arch')"t/*.txt
    t/convert....ok
    All tests successful.
    Files=1, Tests=8, 0 wallclock secs ( 0.03 cusr + 0.03 csys = 0.06 CPU)
    /bin/make/test --OK
    Running make install
    Installing /usr/lib/perl5/site_perl/5.8/auto/Finance/Currency/Convert/autosplit.ix
    Installing /usr/lib/perl5/site_perl/5.8/auto/Finance/Currency/Convert.pm
    Writing /usr/lib/perl5/site_perl/5.8/auto/Finance/Currency/Convert/.packlist
    Appending installation info to /usr/lib/perl5/5.8/msys/perllocal.pod
    /bin/make/install -- OK

【问题讨论】:

  • 这不是最好的解决方法,但您可以在您的 perl 脚本中修改 @INC,然后再修改 use 有问题的包。
  • 我认为这只是构建模块时使用的临时位置,所以看起来它没有安装(如果这是它在您系统上的唯一位置)。您可能想尝试从普通命令窗口运行 CPAN 进行安装。
  • @jswolf19,你的意思是包含minGW位置
  • 既然你有安装问题,也许你应该把你所做的复制下来。
  • @itcplpl,说“一切正常”是完全没有帮助的,因为它显然没有。我对您给出的唯一猜测是 MinGW 安装了自己的 Perl,而您为该 Perl 安装了模块。请重新安装它,并给出输出,好吗?在执行install Finance::TickerSymbols 之前,您可能必须先force get Finance::TickerSymbols(来自cpan shell)才能安全地说服它重新安装已安装的模块。

标签: perl mingw cpan activestate


【解决方案1】:

您需要转到 PPM 并安装 CPAN module

然后,转到您的命令行,运行cpan。然后install Finance::TickerSymbols。 ActiveState 的cpan will check whether or not you need MinGW installed,并在必要时安装它。之后,它将下载并构建Finance::TickerSymbols 模块。

如果这不起作用,请在您的 Perl 脚本中使用 use lib pragma 来指定应该从中加载这些模块的目录:

use lib qw(/usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8);

是的,没错,模块实际上在/usr/lib/perl5。如果您查看您的输出,您会看到这些模块是在 C:\MinGW\msys\1.0\home\ar\.cpan\build\ 中构建的,但是如果您查看日志的末尾,您会看到它们正在安装在 /usr/lib/perl5/site_perl/5.8

Running make install
Installing /usr/lib/perl5/site_perl/5.8/auto/Finance/Currency/Convert/autosplit.ix
Installing /usr/lib/perl5/site_perl/5.8/auto/Finance/Currency/Convert.pm
Writing /usr/lib/perl5/site_perl/5.8/auto/Finance/Currency/Convert/.packlist
Appending installation info to /usr/lib/perl5/5.8/msys/perllocal.pod
/bin/make/install -- OK

您可以做的最后一件事(如果没有其他方法)是切换到Strawberry Perl。这包含使用 CPAN 模块所需的一切。这是拉里沃尔使用的。 Strawberry Perl 从 CPAN 档案中安装该模块没有问题。

【讨论】:

  • 我在安装 minGW 之前安装了 CPAN、CPAN-Meta 和 CPAN-Meta-YAML(通过 PPM),这就是为什么当我从 Windows cmd 运行 cpan 时,它需要我安装 minGW。我刚刚从我的 windows cmd(不是 minGW)运行安装,它现在似乎已经工作了。那么,这是否意味着,对于未来,我应该在 Windows cmd 上使用 cpan 而不是 minGW?
  • @itcplpl:是的。只需在 cmd.exe 外壳下从 Windows 控制台运行 cpan。如果需要,它将安装 MinGW,然后继续安装包。问题是 MinGW 将它安装在 /usr/lib/perl 中,我相信 Perl 库位于 Linux 中。然而,这不是 ActivePerl 寻找它们的地方。
猜你喜欢
  • 2014-01-27
  • 2011-08-07
  • 2018-06-19
  • 2014-12-06
  • 2014-02-18
  • 2013-11-04
  • 2013-09-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多