【发布时间】:2020-08-13 22:56:39
【问题描述】:
我已经成功地从 python 运行了一段时间的 perl 脚本。我刚刚将所有内容移到了新计算机上(两台都运行 Windows 10),但我遇到了问题。
运行脚本时出现错误:
Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains: /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl)
在第一行use DBI;。
我改用Perl (command line),选择了带有脚本的文件夹并运行perl <filename> - 同样的错误。
DBI 似乎已正确安装在C:\Strawberry\perl\vendor\lib 中,当我通过perl -V 检查时,该目录位于我的@INC 中:
@INC:
C:/Strawberry/perl/site/lib
C:/Strawberry/perl/vendor/lib
C:/Strawberry/perl/lib
我尝试使用cpan Module::DBI 再次安装DBI,但出现错误:
Could not expand [Module::DBI]. Check the module name.
我尝试使用perl -MCPAN -e "install Bundle::DBI" 安装它,但失败:
Test Summary Report
-------------------
t/original.t (Wstat: 0 Tests: 27 Failed: 1)
Failed test: 26
Files=1, Tests=27, 1 wallclock secs ( 0.05 usr + 0.01 sys = 0.06 CPU)
Result: FAIL
Failed 1/1 test programs. 1/27 subtests failed.
gmake: *** [Makefile:863: test_dynamic] Error 255
NEILB/IO-Tee-0.65.tar.gz
C:\STRAWB~1\c\bin\gmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports NEILB/IO-Tee-0.65.tar.gz
Stopping: 'install' failed for 'IO::Tee'.
在我以前的机器上进行设置时没有任何问题(这两次都是普通安装,没有导入其他模块)。
我已尝试重新安装草莓几次,但均无济于事。我试过安装 perlbrew 和 ActivePerl,但都遇到了问题。我现在也用尽了 Google 的潜在解决方案。
有什么想法吗?
编辑:
按照here 的建议,我已经运行perl -e "use DBI;" 并且没有错误消息显然意味着DBI 安装正确?
编辑 2
好的,所以我已经设法通过Perl (command line) 和Windows cmd 让事情正常运行——它需要完全重新安装MySQL,但这并没有任何意义,但无论如何。但是,我仍然无法使用Git Bash 执行脚本。我得到了和往常一样的错误......
【问题讨论】:
-
Re "我已经尝试使用
cpan Module::DBI再次安装 DBI",是的,那是因为没有这样的模块。要安装 DBI,您需要cpan DBI。还有一个名为 Bundle::DBI 的伪模块,它具有 DBI 和其他模块作为依赖项,导致所有这些模块都被安装。这就是您最终尝试使用第二个命令安装的内容。 -
Re "按照这里的建议我已经运行 perl -e "use DBI;" 并且没有错误消息显然意味着 DBI 安装正确?" 是的,因为那
perl -
Re "但是,我仍然无法使用 Git Bash 执行脚本。",可能是因为您使用的是为该 unix 仿真环境构建的
perl而不是您为其安装模块的 Strawberry Perl 构建 -
嗨。我肯定只安装了一个 Perl,那就是 Strawberry - 我卸载/删除了 ActiveState 和 perlbrew
-
没有。安装 git 时,就安装了一个完整的 unix 仿真环境,包括 bash、perl 和 git 所需的其他工具。
标签: perl strawberry-perl