• perl安装模块到自己的home ( install perl module without root)


    use local::lib to install perl modules in your home directory ?

    https://metacpan.org/pod/local::lib + http://search.cpan.org/ 
    By default local::lib installs itself and the CPAN modules into ~/perl5.
    Windows users must also see "Differences when using this module under Win32".

    1. Download and unpack the local::lib tarball from CPAN (search for "Download" on the CPAN page about local::lib). Do this as an ordinary user, not as root or administrator. Unpack the file in your home directory or in any other convenient location.

    2. Run this:

        perl Makefile.PL --bootstrap

      If the system asks you whether it should automatically configure as much as possible, you would typically answer yes.

      In order to install local::lib into a directory other than the default, you need to specify the name of the directory when you call bootstrap, as follows:

        perl Makefile.PL --bootstrap=~/foo
    3. Run this: (local::lib assumes you have make installed on your system)

        make test && make install
    4. Now we need to setup the appropriate environment variables, so that Perl starts using our newly generated lib/ directory. If you are using bash or any other Bourne shells, you can add this to your shell startup script this way:

        echo '[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bashrc

      If you are using C shell, you can do this as follows:

        /bin/csh
        echo $SHELL
        /bin/csh
        echo 'eval `perl -I$HOME/perl5/lib/perl5 -Mlocal::lib`' >> ~/.cshrc

      If you passed to bootstrap a directory other than default, you also need to give that as import parameter to the call of the local::lib module like this way:

        echo '[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/foo/lib/perl5 -Mlocal::lib=$HOME/foo)"' >>~/.bashrc

      After writing your shell configuration file, be sure to re-read it to get the changed settings into your current shell's environment. Bourne shells use . ~/.bashrc for this, whereas C shells use source ~/.cshrc.

     

    http://learn.perl.org/faq/perlfaq8.html

    How do I keep my own module/library directory?

    When you build modules, tell Perl where to install the modules.

    If you want to install modules for your own use, the easiest way might be local::libexternal link, which you can download from CPAN. It sets various installation settings for you, and uses those same settings within your programs.

    If you want more flexibility, you need to configure your CPAN client for your particular situation.

    For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:

        perl Makefile.PL INSTALL_BASE=/mydir/perl

    You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:

        % cpan
        cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
        cpan> o conf commit

    For Build.PL-based distributions, use the --install_base option:

        perl Build.PL --install_base /mydir/perl

    You can configure CPAN.pm to automatically use this option too:

        % cpan
        cpan> o conf mbuild_arg "--install_base /mydir/perl"
        cpan> o conf commit

    INSTALL_BASE tells these tools to put your modules into /mydir/perl/lib/perl5. See "How do I add a directory to my include path (@INC) at runtime?" for details on how to run your newly installed modules.

    There is one caveat with INSTALL_BASE, though, since it acts differently from the PREFIX and LIB settings that older versions of ExtUtils::MakeMakerexternal link advocated. INSTALL_BASE does not support installing modules for multiple versions of Perl or different architectures under the same directory. You should consider whether you really want that and, if you do, use the older PREFIX and LIB settings. See the ExtUtils::Makemakerexternal link documentation for more details.

    How do I add a directory to my include path (@INC) at runtime?

    Here are the suggested ways of modifying your include path, including environment variables, run-time switches, and in-code statements:

    the PERLLIB environment variable
        $ export PERLLIB=/path/to/my/dir
        $ perl program.pl
    the PERL5LIB environment variable
        $ export PERL5LIB=/path/to/my/dir
        $ perl program.pl
    the perl -Idir command line flag
        $ perl -I/path/to/my/dir program.pl
    the lib pragma:
        use lib "$ENV{HOME}/myown_perllib";
    the local::libexternal link module:
        use local::lib;
    
        use local::lib "~/myown_perllib";
    
  • 相关阅读:
    python第三周练习
    python第一周作业
    SQLite3—数据库的学习—python
    python实现跳一跳辅助的实验报告
    Python——自己的第一个网页(文件的使用)
    第一次爬虫和测试
    numpy和matplotlib使用
    Python作业———预测球队比赛成绩
    PIL库的学习
    Pytho作业——Jieba库的使用和好玩的词云
  • 原文地址:https://www.cnblogs.com/itech/p/2417874.html
Copyright © 2020-2023  润新知