3

I have looked everywhere on the internet for a solution but haven't found anything helpful.

I am trying to use Cython to embed C code into my python programs.

python setup.py build_ext --inplace

When I run the above it complains about the compiler, not being gcc-4.0. I now know that only gcc-4.2 is installed on Lion (python 2.7 32 bit). Is there anyway of getting 4.0, I tried fink but it doesn't have it. (I have run this on windows and my friends laptop with snow leopard and it runs fine).

If I try specifying the installed gcc I get

error: don't know how to compile C/C++ code on platform 'posix' with 'gcc' compiler

To check the possible compilers I ran:

python setup.py build_ext --inplace --help-compiler

and got these:

List of available compilers:
  --compiler=bcpp     Borland C++ Compiler
  --compiler=cygwin   Cygwin port of GNU C Compiler for Win32
  --compiler=emx      EMX port of GNU C Compiler for OS/2
  --compiler=mingw32  Mingw32 port of GNU C Compiler for Win32
  --compiler=msvc     Microsoft Visual C++
  --compiler=unix     standard UNIX-style compiler

As far as I can see I can't install any of these either.

Is there anything I can do to fix this problem?

3
  • Do you have the Developer Tools/XCode installed?
    – blahdiblah
    Dec 10, 2011 at 2:19
  • Yeah installed xcode but it only comes with gcc-4.2. I think the old gcc-4.0 may have been ppc (?)
    – Anake
    Dec 10, 2011 at 2:30
  • Can you add the error message that you get? It seems weird that it would specify the exact version necessary and not just a minimum version.
    – blahdiblah
    Dec 10, 2011 at 3:08

3 Answers 3

2

I had same problem while compiling greenlet in virtualenv, solved by manually setting desired compiler in file lib/python2.7/config/Makefile.

1

You're probably using an older 32-bit-only Python perhaps installed from python.org. Try upgrading to a 64-/32-bit Python 2.7.2 here or simply use the Apple-supplied Python 2.7.1 in Lion (/usr/bin/python2.7).

0

If I try specifying the installed gcc I get

How did you specify it? Using the environment variable CC?

error: don't know how to compile C/C++ code on platform 'posix' with 'gcc' compiler

Makes me think you passed --compiler=gcc, but as you see in the --help-compiler message it’s not a valid value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.