手动安装 Perl 模块
我已经下载了模块 Digest::SHA1
并将其提取到目录 (../Digest-SHA1-2.13/) ,然后将所有 SHA1.* 文件复制到 (../Digest-SHA1 -2.13/Digest)
,在 perl 脚本中,我做了: use Digest::SHA1; 像这样启动脚本:
perl -I ../Digest-SHA1-2.13/Digest perlscriptname.pl
我收到此错误:
Can't locate loadable object for module Digest::SHA1 in @INC
我假设它与共享库(*.so)有关?,我不知道如何从这里继续。
我可以使用 CPAN (-MCPAN) 模块直接安装它,因为我在该服务器上没有执行此操作的权限,并且只能在本地安装(应用程序运行的位置)。 我的最终目标是使用 Algorithm::CouponCode
,它依赖于 Digest::SHA1
奇怪的是,我有 Digest::SHA1
> 已安装(perl -MDigest::SHA1 -e 'print $Digest::SHA1::VERSION'
显示版本 2.11),仍然Algorithm::CouponCode
(其安装方式与我使用 Digest::SHA1
的方式相同)抱怨它可以在 @INC
中找到它,
谢谢!
I have downloaded the module Digest::SHA1
and extracted it to a directory (../Digest-SHA1-2.13/) , then copied all the SHA1.* files into (../Digest-SHA1-2.13/Digest)
and in the perl script, I did : use Digest::SHA1;
launching the script like this:
perl -I ../Digest-SHA1-2.13/Digest perlscriptname.pl
I get this error:
Can't locate loadable object for module Digest::SHA1 in @INC
I assume it has something to do with a shared library (*.so)?, I have no idea how to continue from here.
I can install it directly using CPAN (-MCPAN) module, as I dont have permissions on that server to do that, and can install only locally (where the application is running).
My final goal is to use Algorithm::CouponCode
which is dependent on Digest::SHA1
The weird part is, that I have Digest::SHA1
installed (perl -MDigest::SHA1 -e 'print $Digest::SHA1::VERSION'
shows version 2.11), still Algorithm::CouponCode
(which is installed the same way I did with Digest::SHA1
) complains it can find it in @INC
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用此方法手动安装 perl 模块:
请注意,某些发行版将具有
Build.PL
文件,而不是Makefile.PL
。在这种情况下,请使用以下配方:(您可能只需运行
make install
和./Build install
即可。)如果您需要更改安装目录,则use:
或
取决于模块的种类。
有关详细信息,请参阅 ExtUtils::MakeMaker::FAQ 的 perldoc和 Module::Build
Use this recipe for manually installing perl modules:
Note that some distributions will have a
Build.PL
file instead ofMakefile.PL
. In that case use this recipe:(You may be able to get by with just running
make install
and./Build install
.)If you need to alter the installation dir then use:
or
depending on the kind of module.
For more info see the perldoc for ExtUtils::MakeMaker::FAQ and Module::Build
Perl 模块有两种:pure-Perl 和 XS。 Pure-Perl 模块完全用 Perl 编写,通常只需将
.pm
文件复制到适当的目录即可安装。 XS 模块是用 Perl 和 C 编写的(XS 由 ExtUtils:: 处理为 C 代码ParseXS 模块)并需要 C 编译器来安装它们。正如 dsolimano 所说,当您没有 root 访问权限时,为系统 Perl 安装 Perl 模块的最简单方法是使用 本地::lib。 (你可以做
local::lib
自己做的同样的事情,但为什么要麻烦呢?)为什么
Digest::SHA1
单独工作但当你使用Algorithm::CouponCode
的原因是系统Perl已经安装了2.11版本的Digest::SHA1
。当您使用-I ../Digest-SHA1-2.13/Digest
时,use Digest::SHA1
将从 ../Digest-SHA1-2.13 中获取 Perl 代码/Digest,但是从 XS 代码构建的共享库不在相应的位置。There are two kinds of Perl module: pure-Perl and XS. Pure-Perl modules are written entirely in Perl, and can usually be installed just by copying the
.pm
files to an appropriate directory. XS modules are written in both Perl and C (XS is processed into C code by the ExtUtils::ParseXS module) and require a C compiler to install them.As dsolimano said, the easiest way to install Perl modules for the system Perl when you don't have root access is to use local::lib. (You could do the same things that
local::lib
does yourself, but why bother?)The reason why
Digest::SHA1
works by itself but not when you're usingAlgorithm::CouponCode
is that the system Perl already has version 2.11 ofDigest::SHA1
installed. When you use-I ../Digest-SHA1-2.13/Digest
, thenuse Digest::SHA1
picks up the Perl code from ../Digest-SHA1-2.13/Digest, but the shared library that would be built from the XS code is not in the corresponding location.有什么原因不能使用 local::lib 吗?
它基本上是一个帮助您使用私有(非系统范围)目录作为 Perl 库目录的工具。
设置完成后,您可以运行类似的命令
,然后您的脚本将使用本地安装的
Algorithm::CouponCode) 副本
。Any reason why you can't use local::lib?
It is basically a tool to help you use a private (non-systemwide) directory as your Perl library directory.
After setting it up, you could run a command like
and then your script would use your locally installed copy of
Algorithm::CouponCode)
.