Can't locate ... in @INC

http://perlmaven.com/cant-locate-in-inc

One of the frequent compile time errors people get from Perl looks like this:Can't locate Acme/NameX.pm in @INC (@INC contains: ... )

Starting from perl version 5.18 it will say:

Can't locate Acme/NameX.pm in @INC (you may need to install the Acme::NameX module) (@INC contains: ... )

This error means your code is trying to load the Acme::NameX module, but cannot find it.

You probably have either use Acme::NameX or require Acme::NameX somewhere in your code.

In order to load this module, Perl will go over the directories listed in an internal array of Perl called @INC. In each directory it will look for a subdirectory called Acme, and inside that subdirectory a file called NameX.pm.

If it cannot find the file, then you will get the above error.
原因:大小写敏感,如use acme::name, it will not find the module Acme::Name.

   没有安装所需模块

  If you have just installed the module, then either it was installed in a non-standard place, or it actually failed the installation.

解决:

If, for some reason it was installed in a non-standard directory, you can change the @INC array in several ways.

转载于:https://www.cnblogs.com/tina-ma/p/4312455.html

在 Perl 中使用 `use Foo;` 语句导入模块时,Perl 会在 `@INC` 数组中搜索 `Foo.pm` 文件。如果找不到该文件,就会报错 `Can't locate Foo.pm in @INC`。 `@INC` 是 Perl 的一个数组,它包含了 Perl 搜索模块文件的路径。当我们使用 `use` 导入模块时,Perl 会在 `@INC` 数组中搜索与模块名相同的 `.pm` 文件。如果找到了该文件,就会执行其中的代码并将模块中定义的函数、变量或常量导入到当前命名空间中。 如果报错 `Can't locate Foo.pm in @INC`,那么可能是以下原因之一: 1. `Foo.pm` 文件不存在。请检查是否存在名为 `Foo.pm` 的文件,以及该文件是否在 `@INC` 中。 2. `Foo.pm` 文件存在,但是没有在 `@INC` 中。可以使用 `use lib` 语句将文件所在目录添加到 `@INC` 中,例如: ``` use lib '/path/to/Foo'; use Foo; ``` 上面的代码会将 `/path/to/Foo` 目录添加到 `@INC` 中,然后使用 `use Foo;` 导入 `Foo` 模块。 3. `Foo.pm` 文件存在,但是没有权限读取。请检查文件权限是否正确,以及当前用户是否有权限读取该文件。 4. `Foo.pm` 文件存在,但是文件名有误。请检查文件名是否为 `Foo.pm`,以及文件名的大小写是否与 `use` 语句中的模块名一致。 5. `Foo.pm` 文件存在,但是文件中有语法错误。请检查文件中的语法是否正确。 总的来说,解决 `Can't locate Foo.pm in @INC` 错误的方法是找到 `Foo.pm` 文件并将其添加到 `@INC` 中,或者将文件所在目录添加到 `@INC` 中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值