如何将默认的 perl 安装更改为 macports 安装的安装
我通过macports安装了perl5.14。
通过输入
which perl
我得到
/usr/bin/perl
How do I Change the perl to point the macports one。
我的 .profile 是:
# MacPorts Installer addition on 2012-02-02_at_14:42:32: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
I installed perl5.14 via macports.
By typing
which perl
I get
/usr/bin/perl
How do I change the perl to point the macports one.
My .profile is:
# MacPorts Installer addition on 2012-02-02_at_14:42:32: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许 perl 端口未激活?尝试:
Maybe the perl port isn't active? try:
您需要重新启动终端才能使
导出
生效。作为一种快速但混乱的解决方法,您始终可以像这样调用 perl:/opt/local/bin/perl
请记住将其也放入 Perl 脚本中。另外,与 unix 不同,我发现在安装到本地目录时总是必须使用 sudo。Macports 非常适合安装 Mac 上未安装的所有非 Perl 库,但是它不太适合安装 Perl 模块,因为它依赖于它的端口,你不能真正使用 CPAN 来安装 Perl 模块。安装。
perlbrew
可以在 Mac 上运行,并且是一个更好的解决方案。但如果您仍然想使用 Macports 安装非 Perl 库,那么您就会遇到问题。我用.profile
解决了这个问题,如下所示:请注意评论。当我打开终端时,第一行给我我的 perlbrew Perl。当我想使用 Macports 安装库时,我交换注释并重新启动终端,然后我就拥有了 Macports Perl。当然,这意味着我的机器上需要两个 Perls,并且它们都需要是相同的版本,但我对此没有任何问题。
You need to re-launch terminal for the
export
to take effect. As a quick but messy workaround you can always invoke perl like this:/opt/local/bin/perl
Remember to put that in your Perl scripts as well. Also, unlike unix I find I always have to usesudo
when installing to a local directory.Macports is great for installing all those non-Perl libraries that aren't installed on the Mac, however it is not so great for installing Perl modules as it is dependant on there being a port of it, you can't really use CPAN to install.
perlbrew
does work on the Mac and is a much better solution. But if you still want to use Macports to install non-Perl libraries you hit a problem. I solved it with a.profile
like this:Note the comment. The first line gives me my perlbrew Perl when I open terminal. When I want to use Macports to install libraries I swap the comment around and re-launch terminal and I then have Macports Perl. Of course this means I need two Perls on my machine, and they both need to be the same version but I don't have any problems with this.
由于我没有使用 Mac,所以无法准确回答您的问题。然而,许多 Perl 用户/开发人员现在使用
perlbrew
来安装较新版本的 Perl 并管理在它们之间进行选择。我相当有信心它可以在 Mac 上运行。如需了解更多信息,请访问网站或CPAN。Not being on a Mac, I cannot answer your exact question. However, many Perl users/developers now use
perlbrew
to install newer versions of Perl and manage choosing between them. I am fairly confident that it works on Mac. Read more at the website or CPAN.