【问题标题】:Perl API Error: Bareword "SQL_INTEGER" not allowed while "strict subs" in usePerl API 错误:使用“strict subs”时不允许使用裸词“SQL_INTEGER”
【发布时间】:2013-11-03 07:45:42
【问题描述】:

我正在尝试使用以下 Perl 代码连接到 Ensembl API:

    #!/bin/perl

    use Bio::EnsEMBL::Registry;
    use DBI qw(:sql_types);


    my $registry = 'Bio::EnsEMBL::Registry';

    $registry->load_registry_from_db(
        -host => 'ensembldb.ensembl.org', # alternatively 'useastdb.ensembl.org'
        -user => 'anonymous'
    );

    my @db_adaptors = @{ $registry->get_all_DBAdaptors() };

    foreach my $db_adaptor (@db_adaptors) {
        my $db_connection = $db_adaptor->dbc();

        printf(
            "species/group\t%s/%s\ndatabase\t%s\nhost:port\t%s:%s\n\n",
            $db_adaptor->species(),   $db_adaptor->group(),
            $db_connection->dbname(), $db_connection->host(),
            $db_connection->port()
        );
    }

Bioperl 和 CPAN 都是使用 Ensembl API 所必需的,我很确定它们已正确安装在我的 Ubuntu 上。我还将所需的模块添加到 PERL5LIB 环境变量中。尽管如此,我还是收到以下错误消息:

    Bareword "SQL_INTEGER" not allowed while "strict subs" in use at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm line 299.
    Compilation failed in require at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm line 45.
    BEGIN failed--compilation aborted at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm line 45.
    Compilation failed in require at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/DBAdaptor.pm line 60.
    BEGIN failed--compilation aborted at /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/DBAdaptor.pm line 60.
    Compilation failed in require at /home/src/ensembl/modules/Bio/EnsEMBL/Registry.pm line 127.
    BEGIN failed--compilation aborted at /home/src/ensembl/modules/Bio/EnsEMBL/Registry.pm line 127.

这里是脚本用来连接 Ensembl 数据库的注册表文件:

    Bio::EnsEMBL::Registry->load_registry_from_db(
        -host    => 'ensembldb.ensembl.org',
        -user    => 'anonymous',
        -verbose => '1'
    );

    use strict;
    use Bio::EnsEMBL::Utils::ConfigRegistry;
    use Bio::EnsEMBL::DBSQL::DBAdaptor;


    new Bio::EnsEMBL::DBSQL::DBAdaptor(
        -host    => 'ensembldb.ensembl.org',
        -user    => 'anonymous',
        -port    => '3306',
        -species => 'homo_sapiens',
        -group   => 'core',
        -dbname  => 'homo_sapiens_core_70_37'
    );

    my @aliases = ( 'H_Sapiens', 'Homo sapiens', 'human' );

    Bio::EnsEMBL::Utils::ConfigRegistry->add_alias(
        -species => 'homo_sapiens',
        -alias   => \@aliases
    );
    1

【问题讨论】:

  • 可能没有导入一些常量?
  • 问题出在您未显示的代码中。
  • 我没有收到任何错误。不太可能是安装错误。更有可能是旧版本的 DBI。 perl -MDBI -le'print $DBI::VERSION' ; perl -Mstrict -MDBI=:sql_types -le'print STDOUT SQL_INTEGER'的输出是什么
  • 命令“perl -MDBI -le'print $DBI::VERSION'”什么也不打印。第二个命令打印“Bareword "SQL_INTEGER" not allowed while "strict subs" in use at -e line 1. 由于编译错误,-e 的执行中止。”
  • 嗯?它不可能什么都不打印?!模块必须有一个版本才能在 CPAN 上。 use DBI; 正在加载 DBI 以外的内容,这意味着您的系统上有垃圾 DBI.pm

标签: perl api cpan dbi bioperl


【解决方案1】:

文件 /home/src/ensembl/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm 在第 299 行之前是否有 use DBI qw(:sql_types); 行?不?也许你有旧版本的 Bio::EnsEMBL::DBSQL::BaseAdaptor。

也许您的 DBI 不是应有的样子。 perldoc -l DBI 说什么是 DBI 的位置?这是正确的吗?你是如何安装 DBI 的?你不只是复制“.pm”文件,对吗?

【讨论】:

  • 我重新安装了 DBI。现在我得到一个不同的错误:“DBD::mysql 初始化失败:无法通过 /usr/local/lib/perl/5.14.2/DBI.pm 行的包“DBD::mysql”找到对象方法“驱动程序” 819"
  • DBD::mysql 安装了吗?
猜你喜欢
  • 2012-11-11
  • 2019-01-17
  • 2019-06-05
  • 2014-04-04
  • 1970-01-01
  • 1970-01-01
  • 2018-02-16
  • 2017-05-03
  • 2016-05-21
相关资源
最近更新 更多