1

I'm on OS X 10.8. My system Python in /usr/bin is version 2.7.2. I made the mistake (?) of installing another version of Python, 2.7.3, via Homebrew. That one's linked from /usr/local/bin. My PYTHONPATH points to the latter; specifically PYTHONPATH=/usr/local/bin:. Is that right?

In any case, bzr --version outputs

Bazaar (bzr) 2.6b2
Python interpreter: /usr/bin/python2.6 2.6.7
Python standard library: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
Platform: Darwin-12.2.1-x86_64-i386-64bit
bzrlib: /Library/Python/2.6/site-packages/bzrlib
Bazaar configuration: /Users/adam/.bazaar
Bazaar log file: /Users/adam/.bzr.log
...

How is Bazaar even finding 2.6.7 and how can I point it to the Homebrew version? I thought that's what PYTHONPATH was for. The problem is that I've installed Python modules via Homebrew and pip and Bazaar can't find them. Ultimately, what I'm trying to do is convert a Bazaar shared repo to Git via fastimport, but that's another question...

6
  • How did you install Bazaar?
    – abarnert
    Mar 14, 2013 at 19:39
  • I installed Bazaar via Homebrew as well.
    – Metaphile
    Mar 14, 2013 at 19:40
  • How did you install it via Homebrew? If you just did brew install bazaar with no arguments, did you do it before or after installing Homebrew Python?
    – abarnert
    Mar 14, 2013 at 19:42
  • Also, with a freshly updated Homebrew, brew info bazaar tells me bazaar: stable 2.5.1. But you've got 2.6b2. Are you sure you installed it via Homebrew at all?
    – abarnert
    Mar 14, 2013 at 19:45
  • I just checked and /usr/local/bin/bzr is NOT a symlink as it would be after a successful Homebrew install. So that was definitely part of my problem. Now that I think about it, I vaguely remember using the Canonical installer at one point in the past. Man, what a day... OK, so I reinstalled Bazaar via Homebrew and forced the linking step and ... I'll get back with you in just a sec.
    – Metaphile
    Mar 14, 2013 at 19:50

3 Answers 3

2

First, notice that 10.8 comes with 2.5, 2.6, and 2.7, all available as /usr/bin/python2.*.

Next, how did you install Bazaar?

I'm guessing you installed a binary package, and it was specifically packaged to rely on /usr/bin/python2.6 because that version is there in all OS X 10.5+ versions, or because that's what they tested on, or… whatever.

(It's also possible you installed it via, say, easy_install-2.6, or some indirect equivalent of the same thing. But that seems like a silly thing to do.)

If you want Bazaar to use packages you've installed via Homebrew, you're probably going to want to use either Homebrew itself, or the pip from Homebrew's Python, to install Bazaar.


From a comment, you said you vaguely remember running the installer from Canonical. As their Mac OS X Downloads and Installation page makes clear, what you downloaded is for "Snow Leopard (10.6 - Python 2.6)". (Also, you downloaded the "Test" version instead of the stable, given that you have 2.6b1.) It even says:

At some point the installer will be able to use 2.7 but for now this is the easiest way to get Bazaar working with Lion.

So, this is all documented pretty clearly. Their installer uses Apple's system Python, and specifically uses 2.6 for OS X 10.6+.


Since Bazaar is pure Python code, the way it's finding 2.6 is simple: The first line of /usr/local/bin/bzr is something like this:

#!/usr/bin/python2.6

or:

#!/usr/bin/env python2.6

You could hack that up to, say, #!/usr/local/bin/python2.7. But that's a very bad idea. You've got something that installed and configured itself against one Python, you don't want to try to run it against another. (Since it's pure Python code, it will mostly work, but sometimes fail in mysterious ways, which is probably worse than code that uses C extensions or embedding which will probably just fail immediately.)

1

$PYTHONPATH is used to specify the location of extra python libraries (very similar to adding the path to python's sys.path) and not the python interpreter itself. I'm guessing your system is picking up the version of python, which is found first in $PATH.

It might be that you have another version of Python installed which gets pulled from $PATH.

You can run which python to figure out the exact python binary which is being used.

6
  • It's incredibly unlikely that /usr/bin/python2.6 is the highest thing on his path as python. OS X comes with /usr/bin/python as a binary wrapper that ultimately points to the same installation as /usr/bin/python2.7. Besides, which python couldn't possibly return /usr/bin/python2.6.
    – abarnert
    Mar 14, 2013 at 19:38
  • There is also update-alternatives which is used to maintain multiple versions of same package, which it not exactly a binary wrapper but just uses symlinks to choose the right version of a binary.
    – Tuxdude
    Mar 14, 2013 at 19:40
  • 1
    update-alternatives is a Debian-ism; it doesn't exist on OS X or other Unixes, or even many non-Debian-based lines. Also, OS X does not use symlinks to select the right Python. Again, /usr/bin/python is always a binary wrapper that selects the right actual binary out of /System/Frameworks (which has to be Apple's 2.7, so I'm not sure why they bothered with it, but that's what it does). Your information is both irrelevant and misleading.
    – abarnert
    Mar 14, 2013 at 19:44
  • 1
    You didn't notice him talking about using Homebrew instead of apt, or think anything strange about libraries being in "frameworks" or having paths inside /System/Library or any of the rest of it?
    – abarnert
    Mar 14, 2013 at 19:51
  • 1
    @Tuxdude How about the first line where I mention I'm on OS X 10.8? ;D
    – Metaphile
    Mar 14, 2013 at 19:53
1

I build the official Mac OS X installer packages for Bazaar. However, I am not employed by Canonical.

If you're using the Bazaar installer package downloaded from the Canonical website, then it is built specifically against Python 2.6 and the bzr script uses /usr/bin/python2.6 in its header to ensure that it is invoked with Python 2.6. There are some native Python extensions which are compiled against Python 2.6 when I build the installer, so running it with another major version of Python may not work (I've never tried).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .