MacPorts和bash路径 [英] MacPorts and the bash PATH

查看:108
本文介绍了MacPorts和bash路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用10.8.1(Mountain Lion).

I am using 10.8.1 (Mountain Lion).

升级到Mountain Lion之后,我的某些MacPorts停止了工作.为了使生活更轻松,我只需清除/opt/local/并重新安装最新版本的MacPorts,然后再安装端口本身.

After upgrading to Mountain Lion, some of my MacPorts stopped working. For an easier life, I simply cleared out /opt/local/ and reinstalled the latest version of MacPorts, followed by the ports themselves.

这产生的副作用是,我使用的许多端口已恢复为捆绑的OS X默认值.我打开了 .profile 以确保/opt/local/bin 在PATH中排在首位,但这并没有解决问题.

This has had the side-effect that many of the ports I was using have gone back to their bundled OS X defaults. I opened up .profile to make sure that /opt/local/bin came first in the PATH, but that hasn't solved the problem.

我怀疑 port select 的输出是一种症状:

I suspect the output of port select is a symptom:

$ port select python
Available versions for python:
    none (active)  # shouldn't the bundled version be here?
    python27
    python32

$ which python
/usr/bin/python

更改活动端口()可以解决此问题,但并非所有端口都可以与 port select 一起使用.有人知道这是怎么回事吗?

Changing the active port (sudo port select --set python python27) solves the problem, but not all ports work with port select. Does anyone know what's going on here?

编辑:我应该澄清一下,我认为这并不是一个完整的解决方法-您应该可以使用 sudo port select这样的命令将其改回Apple版本.--set python python25-apple ,我怀疑我只能通过解决根本问题才能回来.

Edit: I should clarify that I don't consider this a complete fix - you're supposed to be able to change back to the Apple version with a command like sudo port select --set python python25-apple, which I suspect I'll only get back by solving the underlying problem.

为记录,〜/.profile 的内容:

export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin

推荐答案

没有更多信息,很难猜测您正在看到的行为以及期望看到的行为.MacPorts确实为您提到的某些命令提供了 port select 选项,例如 python ipython ,但

Without more information, it's hard to guess what behavior you are seeing and what you expect to see. MacPorts does provide port select options for some of the commands you mention like python and ipython but does not yet for pip. In general, MacPorts installs Python scripts with version-specific suffixes, so independent of port select options, you should find those commands with their suffix, for example:

$ port select --list ipython
Available versions for ipython:
    ipython27
    ipython32 (active)
    none
$ which ipython
/opt/local/bin/ipython
$ which ipython-2.7
/opt/local/bin/ipython-2.7
$ port select --list pip
Warning: Unable to get active selected version: The specified group 'pip' does not exist.
Error: The 'list' command failed: The specified group 'pip' does not exist.
$ which pip
$ which pip-2.7
/opt/local/bin/pip-2.7

BTW,Apple不提供OS X系统Python来提供 pip ipython ,因此不清楚捆绑的OS X默认值是什么意思.也许您已将这些版本安装到系统python 2.7中.如果是这样,默认情况下,您会看到它们带有/usr/bin/python2.7 和/或安装在/usr/local/bin /Library中/Python/2.7.

BTW, neither pip nor ipython are supplied by Apple with OS X system Pythons, so it's not clear what you mean by bundled OS X defaults. Perhaps you installed versions of these to the system Python 2.7. If so, by default, you would see them with /usr/bin/python2.7 and/or installed in /usr/local/bin and /Library/Python/2.7.

更新:在MacPorts提供一个 port select pip 选项(如上面链接的MacPorts问题中所述)之前,您应该能够拥有 pip .profile 在路径的开头添加Python框架bin目录,可以执行MacPorts版本:

Update: Until MacPorts provides a port select pip option (as requested in the MacPorts issue linked above), you should be able to have pip execute the MacPorts version by modifying your .profile to add the Python framework bin directory at the head of the paths:

export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:...

更新2014-04::MacPorts现在确实提供了 port select pip 选项,因此您不再需要进行 PATH hack.

Update 2014-04: MacPorts now does provide a port select pip option so you should no longer need to do the PATH hack.

$ sudo port select pip
Available versions for pip:
    none (active)
    pip27
    pip33
$ sudo port select pip pip27
Selecting 'pip27' for 'pip' succeeded. 'pip27' is now active.
$ hash
$ which pip
/opt/local/bin/pip

这篇关于MacPorts和bash路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆