2

I am setting up Python and Django on os X 10.7 from a virgin install and Xcode 4.3.

I tried using the default install of Python:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

I normally use a Python based package manager called easy_install. Easy_install seems to not be able to find the compiler.

EDIT: When I tried to install MySQL-python I got this error:

$ sudo easy_install MySQL-python 
Password:
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P9H9WX/MySQL-python-1.2.3/egg-dist-tmp-rRTfZL
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
unable to execute llvm-gcc-4.2: No such file or directory
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1

error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1
Apparently, the system attempts to use the same compiler used to compile the installed Python framework. For some reason Apple didn't include llvm-gcc-4.2.

Xcode 4.1 used GCC, but with Xcode 4.3 that seems to have changed.
From what I can gather, Apple wants to use Clang as the compiler vs GCC. So I added to .bash_profile:

cc=clang

I decided I would just recompile Python with clang but first, I needed to install readline.
Fail:

Wed Feb 22 16:04:59 ~/Downloads/readline-6.2 
$ ./configure
checking build system type... i386-apple-darwin11.3.0
checking host system type... i386-apple-darwin11.3.0

Beginning configuration for readline-6.2 for i386-apple-darwin11.3.0

checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Bryan/Downloads/readline-6.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

What the easiest way to install Django on Lion 10.7?

BryanWheelock
  • 12,146
  • 18
  • 64
  • 109
  • Install a python package from their website, don't compile it yourself. The default python install on OSX seems to have some customizations. I'm running python 2.7.2 + Django with no problems on Lion. – Endophage Feb 22 '12 at 21:41
  • `pip install mysql-python` or `easy_install mysql-python` if pip isn't installed for some reason – Endophage Feb 27 '12 at 20:31
  • I still got error: command 'gcc-4.2' failed with exit status 1 when I used pip. https://gist.github.com/1944216 – BryanWheelock Feb 29 '12 at 20:37
  • Looks like you don't have xcode installed and hence, don't have gcc. Install xcode from the app store. Note, the app store "install" actually just downloads the xcode installer that you have to run afterwards. – Endophage Feb 29 '12 at 20:47
  • Ignore my last comment. I just noticed you said you have Xcode 4.3. I don't know how to help you there beyond suggesting you install gcc 4.2. I'm running Xcode 4.1 as I installed it a while ago and didn't upgrade... – Endophage Feb 29 '12 at 20:51

4 Answers4

13

Did you install the command-line tools with Xcode 4.3? They are not installed by default. You can install them by going to the Downloads pane in Xcode 4.3's preferences.

mipadi
  • 398,885
  • 90
  • 523
  • 479
0

Try updating XCode and reinstall all global site-packages. You may also want to try pip instead of easy_install.

You can also try to compile with

export ARCHFLAGS='-arch i386 -arch x86_64'

This solved many of my problems in the past when upgrading OSX versions.

Ima
  • 680
  • 1
  • 15
  • 28
0

Making it way too hard:

First, make sure you install Xcode (available for free in the Mac App Store). It includes all the build tools that might be necessary to compile certain Python packages.

To get easy_install just download setuptools and follow the instructions for installing on Mac OS X at that link.

Once that's done, you can easy_install virtualenv to get a nice segregated environment to work in.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
0

For the MySQL issue you have to edit the site.cfgfile:

mysql_config = /usr/local/mysql/bin/mysql_config

And then:

$ python setup.py build
$ sudo python setup.py install
Stan
  • 8,710
  • 2
  • 29
  • 31