无法找到 Switch.pm

35

我该如何解决这个错误?

Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] Error 2

3
你能否尝试描述一下你正在尝试做什么?这与Android有什么关系,你是在尝试在Android脚本环境中运行它吗?你是否尝试安装Switch模块,就像错误消息本身所说的那样? - Sundar R
2
对于其他遇到这个问题的人,我遇到了这个问题,试图执行AOSP Android构建。这就是与Android有关的问题。 - Michael Burr
1
在创建FHEM中的pilight_ctrl设备时,我遇到了这个错误消息。@yurishi的答案在我的树莓派上为我解决了这个问题。 - tmuecksch
7个回答

60

在Linux Mint上,我必须输入

$ sudo apt-get install libswitch-perl

6
上述命令在我的Ubuntu 14.04 LTS上也可以运行,并且已经成功解决了错误。 - Ashwin
我遇到了一个错误:debconf: Perl 可能未配置(在 @INC 中找不到 strict.pm(您可能需要安装 strict 模块)(@INC 包含:/etc/perl - IgorGanapolsky

13
您之所以收到此错误是因为您的系统上未安装 Switch.pm Perl 模块。有两种方法可以安装它,这两种方法都适用于 Ubuntu 14.04。 1. 通过Ubuntu存储库安装。 2. 通过CPAN安装 .pm 文件。
使用 Ubuntu 存储库安装 Switch.pm: 从命令行完成安装,只需在终端(Ctrl-Alt-t)中运行以下命令即可:
 sudo apt-get install libswitch-perl

使用 CPAN 安装 Switch.pm:

如果您希望通过 cpan 安装此模块,请按照以下说明进行操作:

Open a terminal(Ctrl-Alt-t).

Enter the command cpan.

At the prompt cpan[1]>, type install Switch.

Once completed, Type exit.

鸣谢:Kevin Bowen


2
@IgorGanapolsky 看起来您没有安装 Perl 包。请使用以下命令进行安装:sudo apt-get install perl。 - 4aRk Kn1gh7

9

您可以通过安装"perl-Switch"解决此错误。

对于亚马逊Linux / 红帽 / Centos / 等操作系统:

sudo yum install -y perl-Switch

对于Ubuntu

sudo apt-get install -y libswitch-perl

该命令会产生一个错误:debconf: Perl 可能未配置(在 @INC 中找不到 strict.pm(您可能需要安装 strict 模块)(@INC 包含:/etc/perl) - IgorGanapolsky
@JoseNobile 我相信 apt - IgorGanapolsky
2
@IgorGanapolsky 这里有几个你可以应用的修复方法:https://answers.launchpad.net/ubuntu/+question/233317 - Jose Nobile

3
如果只有一个 Perl 版本,
sudo apt-get install libswitch-perl 

可以解决问题。

但是如果您的系统中存在多个版本的Perl,就像我一样,首先选择5.18版本用于aosp v4.x,然后使用cpan命令安装Swtich,就像@4aRk Kn1gh7的回答一样。

还要注意,在某些Perl脚本中,第一行是:

#! /usr/bin/perl

因此,请确保 /usr/bin/perl 是您选择的正确 Perl 版本。


2
我已经解决了这个问题,实际上我正在使用14.04LTS来编译Android 4.2 Jellybean源代码。 在14.04LTS中,需要安装开关模块。以下是安装过程:
1:使用以下命令并配置为自动 $cpan App::cpanminus
2:安装switch $cpanm Switch
注意:通过使用这两个命令,我的Ubuntu 14.04LTS的问题得到了解决...

0

如果你有Mac:

sudo cpan -f Switch

local::lib选项对我无效。


0

试试 CPAN。在 Fedora 25 上对我有用。

cpan
cpan[1]> install Switch

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接