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...

Metaphile
  • 225

3 Answers3

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.)

abarnert
  • 361
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.

Tuxdude
  • 709
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).

dOxxx
  • 131