Perl的@INC路径中未包含已安装的模块 [英] Installed Module not contained in the Perl's @INC path

查看:38
本文介绍了Perl的@INC路径中未包含已安装的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将Excel-Writer-XLSX模块包含在@INC路径中时遇到问题.在发布此问题之前,我进行了一些研究,并尝试了几种解决方案,但都失败了.

所以我做了

I have an issue on including the Excel-Writer-XLSX module in the @INC path. I did some research before posting this question and tried several solutions, but they all failed.

So I did

$sudo perl -MCPAN -e 'install Excel::Writer::XLSX'

但是在运行代码之后,我收到了此消息

But after I run the code, I got this message

--can't locate Excel/Writer/XLSX.pm in @INC(you may need to install the Excel::Writer::XLSX module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level/...)

这不是重复的问题,因为Excel :: Writer :: XLSX模块已成功安装在我的计算机中,不需要再次安装.问题是当我检查库文件夹时,perl5文件夹不存在,这是@INC路径建议的.相反,Perl5文件夹位于我的用户文件夹中...实际上,该模块可以在perl5文件夹内的lib文件夹中找到

我不太确定发生了什么...为什么@INC路径显示perl/5.18在库文件夹中?如果您知道如何解决此问题,请提出建议.非常感谢!

This is not a duplicate question, because the Excel::Writer::XLSX module has been successfully installed in my computer and I don't need to install it again. The thing is when I checked my library folder, the perl5 folder is not there, as it was suggested by the @INC path. Instead, Perl5 folder is in my user folder...and actually the module can be found in the lib folder inside the perl5 folder

I'm not quite sure what is happening...Why the @INC path shows the perl/5.18 is inside the library folder? If you know how to solve this issue, please advice. Thank you so much!

推荐答案

在您的perl代码的最顶部,紧随#!/usr/bin/perl

At the very top of your perl code right after #!/usr/bin/perl

BEGIN
{
push(@INC, '/home/penny/perlModules');
}
use my::module;
use File::Path;
...

这将允许您的代码使用您在perlModules目录中安装的任何模块.

This will allow your code to use any module you've installed in perlModules dir.

缺点是您必须修改代码.或者,您可以使用上面回答的PERL5LIB环境路径.

Downside is you have to modify code. Or you can use PERL5LIB env path as answered above.

这篇关于Perl的@INC路径中未包含已安装的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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