Tutorial:Installing Perl modules

From BioPerl
Jump to: navigation, search

Contents

The Easy Way

Open a command line terminal and enter either:

ppm install Your::Module::Name

or:

cpan install Your::Module::Name

In Unix based systems such as Linux and Mac OS X, you may need to prefix these commands with "sudo":

sudo ppm install Your::Module::Name

or:

sudo cpan install Your::Module::Name

Perl Module Installation

How to install modules on your computer.

Authors
Jason Stajich
Mauricio Herrera Cuadra
Koen van der Drift
Ayman
Version Comments Author
0.01 Initial skeleton jason stajich 15:45, 27 January 2006 (EST)
0.02 FreeBSD info. Notes to 'Mac OS X using fink' & others Mauricio 13:49, 29 January 2006 (EST)
0.03 Mac OS X using fink Driftkop 06:55, 30 January 2006 (EST)
0.04 Debian Ayman 08:54, 13 September 2006 (EST)
0.05 OpenBSD basic info Mauricio 12:27, 13 September 2006 (EDT)

How does Perl find modules

To see the search path that

perldoc -v List::Util

Perl Include Path

perl -V
Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
 Platform:
   osname=darwin, osvers=8.0, archname=darwin-thread-multi-2level
   uname='darwin b28.apple.com 8.0 darwin kernel version 7.5.0: thu mar 3 18:48:46 pst 2005; root:xnuxnu-517.99.13.obj~1release_ppc power macintosh powerpc '
   config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib'
   hint=recommended, useposix=true, d_sigaction=define
   usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
   useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
   use64bitint=undef use64bitall=undef uselongdouble=undef
   usemymalloc=n, bincompat5005=undef
 Compiler:
   cc='cc', ccflags ='-g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include',
   optimize='-Os',
   cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include'
   ccversion=, gccversion='3.3 20030304 (Apple Computer, Inc. build 1809)', gccosandvers=
   intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
   d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
   ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
   alignbytes=8, prototype=define
 Linker and Libraries:
   ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/usr/local/lib'
   libpth=/usr/local/lib /usr/lib
   libs=-ldbm -ldl -lm -lc
   perllibs=-ldl -lm -lc
   libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib
   gnulibc_version=
 Dynamic Linking:
   dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
   cccdlflags=' ', lddlflags='-bundle -undefined dynamic_lookup -L/usr/local/lib'


Characteristics of this binary (from libperl):

 Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
 Locally applied patches:
       23953 - fix for File::Path::rmtree CAN-2004-0452 security issue
       33990 - fix for setuid perl security issues
 Built under darwin
 Compiled at Mar 20 2005 16:34:19
 %ENV:
 @INC:
   /System/Library/Perl/5.8.6/darwin-thread-multi-2level
   /System/Library/Perl/5.8.6
   /Library/Perl/5.8.6/darwin-thread-multi-2level
   /Library/Perl/5.8.6
   /Library/Perl
   /Network/Library/Perl/5.8.6/darwin-thread-multi-2level
   /Network/Library/Perl/5.8.6
   /Network/Library/Perl
   /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level
   /System/Library/Perl/Extras/5.8.6
   /Library/Perl/5.8.1
   .

If we set $PERL5LIB to be $HOME/lib/perl

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:

 Platform:
   osname=darwin, osvers=8.0, archname=darwin-thread-multi-2level
   uname='darwin b28.apple.com 8.0 darwin kernel version 7.5.0: thu mar 3 18:48:46 pst 2005; root:xnuxnu-517.99.13.obj~1release_ppc power macintosh powerpc '
   config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib'
   hint=recommended, useposix=true, d_sigaction=define
   usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
   useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
   use64bitint=undef use64bitall=undef uselongdouble=undef
   usemymalloc=n, bincompat5005=undef
 Compiler:
   cc='cc', ccflags ='-g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include',
   optimize='-Os',
   cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include'
   ccversion=, gccversion='3.3 20030304 (Apple Computer, Inc. build 1809)', gccosandvers=
   intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
   d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
   ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
   alignbytes=8, prototype=define
 Linker and Libraries:
   ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/usr/local/lib'
   libpth=/usr/local/lib /usr/lib
   libs=-ldbm -ldl -lm -lc
   perllibs=-ldl -lm -lc
   libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib
   gnulibc_version=
 Dynamic Linking:
   dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
   cccdlflags=' ', lddlflags='-bundle -undefined dynamic_lookup -L/usr/local/lib'


Characteristics of this binary (from libperl):

 Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
 Locally applied patches:
       23953 - fix for File::Path::rmtree CAN-2004-0452 security issue
       33990 - fix for setuid perl security issues
 Built under darwin
 Compiled at Mar 20 2005 16:34:19
 %ENV:
   PERL5LIB="/Users/jason/lib/perl"
 @INC:
   /Users/jason/lib/perl/darwin-thread-multi-2level
   /Users/jason/lib/perl
   /System/Library/Perl/5.8.6/darwin-thread-multi-2level
   /System/Library/Perl/5.8.6
   /Library/Perl/5.8.6/darwin-thread-multi-2level
   /Library/Perl/5.8.6
   /Library/Perl
   /Network/Library/Perl/5.8.6/darwin-thread-multi-2level
   /Network/Library/Perl/5.8.6
   /Network/Library/Perl
   /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level
   /System/Library/Perl/Extras/5.8.6
   /Library/Perl/5.8.1
   .

Installing with pre-packaged systems

Several pre-built systems exist for installing Perl modules.

RedHat, Fedora, Centos RPMs

These are typically prefixed with perl-

Debian

You can easily install Perl modules using apt-get, the package name usually starts with lib and ends with -perl like: libsomething-perl. For e.g. libarray-compare-perl, libarchive-zip-perl, libnet-pcap-perl or libnet-dns-perl.

  • To search for package run: apt-cache search string
  • To install a package run: apt-get install packagename. For e.g. apt-get install libnet-dns-perl
  • To read more info about the package: apt-cache show libnet-dns-perl. Output from my box:
$ apt-cache show libnet-dns-perl
Package: libnet-dns-perl
Priority: optional
Section: perl
Installed-Size: 808
Maintainer: Florian Hinzmann <fh@debian.org>
Architecture: i386
Version: 0.57-1
Depends: perlapi-5.8.8, perl (>= 5.8.8-3), libc6 (>= 2.3.5-1), libdigest-hmac-perl, libmime-base64-perl, libnet-ip-perl
Filename: pool/main/libn/libnet-dns-perl/libnet-dns-perl_0.57-1_i386.deb
Size: 245502
MD5sum: ff8771b57ea3c19e7777744e01231943
SHA1: bb8fd3fc84b56566663f72bfbaa229507d87afb8
SHA256: fffab22c83f5e22059685ac8d525b19533ea05a8a83b52ff01f2e8f564291e35
Description: Perform DNS queries from a Perl script
Net::DNS is a DNS resolver implemented in Perl.  It allows the
programmer to perform nearly any type of DNS query from a Perl
script.
Tag: devel::library, langdevel::perl, made-of::lang:perl, protocol::dns, role::sw:shlib

If you can't find the package name for the module you want, you can use the great tool apt-file to search by filenames in the package. For example, if you are looking for the Perl module DNS.pm run:

$ apt-file search DNS.pm
bastille: usr/lib/Bastille/DNS.pm
bastille: usr/lib/Bastille/test_DNS.pm
libnet-dns-perl: usr/lib/perl5/Net/DNS.pm
libpoe-component-client-dns-perl: usr/share/perl5/POE/Component/Client/DNS.pm
pike7.6-core: usr/lib/pike/7.6.75/lib/modules/Protocols.pmod/DNS.pmod
pike7.6-core: usr/share/pike/7.6.75/lib/modules/Protocols.pmod/DNS.pmod
slimp3: usr/share/perl5/SliMP3/mDNS.pm
slimserver: usr/share/perl5/SlimServer/Slim/Networking/mDNS.pm
smokeping: usr/share/perl5/smokeping/Smokeping/probes/AnotherDNS.pm
smokeping: usr/share/perl5/smokeping/Smokeping/probes/CiscoRTTMonDNS.pm
smokeping: usr/share/perl5/smokeping/Smokeping/probes/DNS.pm

these are all the packages containing a file named *DNS.pm*
you can install any by of them by: apt-get install package

FreeBSD

The most easy way of installing Perl modules in FreeBSD is through the Ports Collection. If you're new to this procedure please take a look at this document.

The first step is to make sure that the Perl module you want actually exists in the ports tree. You can search for it using this interface. Every Perl port in FreeBSD is prefixed with p5-. If the Perl module exists, all you need to do is to update your ports tree and execute some simple commands as root.

Installing Bio::ASN1::EntrezGene as an example:

# cd /usr/ports/biology/p5-Bio-ASN1-EntrezGene
# make install clean

Due to the great architecture of the ports system, this simple commands will automatically fetch and install the selected Perl module (as well as its necessary dependencies).

If you find that the Perl module you want doesn't exist in the Ports Collection, it's also very easy to install it using the CPAN.pm or direct methods described later in this page.

Note: This is the general method for installing any Perl module in a FreeBSD system. If you simply want to install any of the BioPerl releases, then have a look at the FreeBSD section of the Getting BioPerl page.

OpenBSD

OpenBSD users: please help us with this section.

Just as in FreeBSD, the most easy way of installing Perl modules in OpenBSD is by using the ports tree. The OpenBSD ports system works in the same way as the FreeBSD one (the concept is borrowed from FreeBSD), nevertheless, its configuration is a bit different. This document explains with detail the necessary steps to install packages and ports in OpenBSD.

Mac OS X using fink

Before installing a perl module on Mac OS X, several other packages and perl modules may need to be installed. The fink package manager will make it easy to download and install all the required packages and modules. To learn more about installing and using fink read this and this.

To find if the perlmodule that you want to install is available through fink, go to this page, then follow the link for the module. Most modules have a 'versioned' number at the end, meaning that it is only compatible with a particular perl release. If the module is available for your system, the package can be installed as follows (bioperl example on perl 5.8.6):

fink install bioperl-pm586

Installing with CPAN.pm

The CPAN module provides a shell and interface to installation of modules.

Installing directly

Defaults

$ perl Makefile.PL
$ make
$ make test
$ make install

Local home install

$ perl Makefile.PL LIB=$HOME/lib/perl PREFIX=$HOME
Personal tools
Namespaces
Variants
Actions
Main Links
documentation
community
development
Toolbox