views:

263

answers:

5

I have Mac OSX 10.5.8 with Xcode installed. I want to avoid MacPorts and want to just get a solid Python install foundation so I can then move on to mess with Django and other things. I want to use Buildout with my Python applications.

I have installed binary Python 2.6.4 from the official site and installed this. Following other advice I have put this in my ~/.bash_profile file:

export PATH=/usr/local/bin:$PATH

So, when I do a 'which python' it shows '/usr/local/bin/python'. And, when I do a 'python -V' it shows 'Python 2.6.4' - this all seems great.

I've looked inside the '/usr/local/bin/' folder and, among other things, I seem to have the correct stuff pointing to Python 2.6:

python -> ../../../Library/Frameworks/Python.framework/Versions/2.6/bin/python

BUT, when I do an easy_install of virtualenv (that I want to use with Buildout) it seems to install it in: /Library/Python/2.5/site-packages/virtualenv-1.4.3-py2.5.egg

...which is Python 2.5? ...also, when I setup my Buildout folder using virtualenv, in there the .Python symlink is going to:

.Python -> /System/Library/Frameworks/Python.framework/Versions/2.5/Python

Why is this? I don't understand this. How can I get it all pointing to the correct Python 2.6?

Thank you so much for any answers, it's annoying the hell out of me. Cheers.

A: 

Personally, what I do is leave my system python completely as is.

I use the following to install 2.4, 2.5 and 2.6 versions of Python:

Use a buildout from the plone collective to get python2.{4,5,6} installed with easy_install and PIL (including libjpeg support)

Checkout the python buildout files from the plone collective. I like to put it in /home/dev/python-buildout

# svn co http://svn.plone.org/svn/collective/buildout/python /home/dev/python-buildout

Add a new local.cfg file into the src directory. This is where you specify what you want to build. Use the following in your buildout file:

[buildout]  
extends =  
  base.cfg  
  readline.cfg  
  libjpeg.cfg  
  python24.cfg  
  python25.cfg
  python26.cfg
  links.cfg  

parts =  
   ${buildout:base-parts}  
   ${buildout:readline-parts}  
   ${buildout:libjpeg-parts}  
   ${buildout:python24-parts}  
   ${buildout:python25-parts}  
   ${buildout:python26-parts}  
   ${buildout:links-parts}  

Bootstrap with your system python and then run the buildout.

# python bootstrap.py  
# ./bin/buildout -c src/local.cfg

When everything has been compiled, you should have a new python binaries here:

/home/dev/python-buildout/src/python-2.{4,5,6}/bin/python

To use them, either add the bin directory to your path, or source the 'activate' script in the bin directory, which will set it as the active python in your current shell

daniel@madmax # which python   
/usr/bin/python  
daniel@madmax # python -V  
Python 2.6.1  

daniel@madmax # source /home/dev/python-buildout/src/python-2.4/bin/activate
(python-2.4)daniel@madmax # which python   
/home/dev/python-buildout/src/python-2.4/bin/python  
(python-2.4)daniel@madmax # python -V  
Python 2.4.6  

daniel@madmax # source /home/dev/python-buildout/src/python-2.6/bin/activate
(python-2.6)daniel@madmax # which python   
/home/dev/python-buildout/src/python-2.6/bin/python  
(python-2.6)daniel@madmax # python -V  
Python 2.6.4

For each project I'm working on, I tend to create a new virtual environment, using no-site-packages and the appropriate version of Python.

DisplacedAussie
A: 

PirosBOX:~ piros$ python -V Python 2.5.1

Have OSX 10.5.8 and i write django apps fine :D The important thing is to get the SVN release of Django, better!

PirosB3
+1  A: 

Firstly, there's absolutely no need to install a new version of Python to work on Django in Leopard. The stock Python 2.5 works absolutely fine, and Django is 100% compatible with that version.

Secondly, if you do want to use virtualenv with a different version of Python other than the system default, you simply need to tell it when you create the virtualenv:

virtualenv --python=/path/to/python/2.6 virtualenvname
Daniel Roseman
A: 

When you install a new Python instance, you also need to install a new copy of easy_install for it. Follow the instructions for either the classic setuptools version or the newer Distribute. In either case, for the python.org 2.6.4 on OS X the easy_install script will be installed in /Library/Frameworks/Python.framework/Versions/2.6/bin which should come before /usr/bin on your shell $PATH.

Ned Deily