1

I'm trying to use Scrapy inside a virtualenv, which requires installation of twisted as well. I did pip install Scrapy with no problems, but when I try pip install twisted, I'm getting the following error multiple times in the output:

unable to execute gcc-4.0: No such file or directory

error: command 'gcc-4.0' failed with exit status 1

I previously had a similar problem when trying to install python packages on my actual system, which is why I started using virtualenv in the first place. Is this an issue of the python version installed on my environment? This is what I currently have:

Django          - 1.5          - active 
Python          - 2.7.3        - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload)
Scrapy          - 0.16.4       - active 
pip             - 1.2.1        - active 
setuptools      - 0.6c11       - active 
wsgiref         - 0.1.2        - active development (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7)
yolk            - 0.4.3        - active

To check which version of gcc I have I typed gcc at the command line and got

i686-apple-darwin11-llvm-gcc-4.2: no input files

I tried export CC=gcc-4.2 before running pip install twisted, and I got:

llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory

lipo: can't figure out the architecture type of: /var/folders/s8/d0f65gc93nbchdk52g2cg5f80000gn/T//ccWQa7cJ.out

error: command 'gcc-4.2' failed with exit status 255

It sort of looks to me like it's looking for powerpc-apple-darwin11-llvm-gcc-4.2, and what I have above is i686-apple-darwin11-llvm-gcc-4.2--are these different and therefore causing the problem?

To give more background info, I installed Python 2.7 from a Python.org installer a long time ago before upgrading from Snow Leopard straight to Mountain Lion. If I simply type in python at the command line I get

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:32:06) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

So I'm guessing that means I'm using Apple's Python? And it's built with gcc-4.0.1? So if that's the case, shouldn't I not need to do the export CC=gcc-4.2? Or do I need to do that AND switch to the Python.org version of Python? (And if the latter, how do I do that?)

Update: I tried this solution for switching Python versions but it didn't work.

Update: I managed to switch Python versions (outside of my virtualenv) using the sudo port select --set python python27 command, but this didn't solve the problem even though I'm now showing:

Python 2.7.3 (default, Nov 17 2012, 19:54:34) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin

when I type python at the commmand line.

Update: I also found this solution to a question that seemed to have almost the exact same issues as I'm having, but I'm already upgraded to XCode 4.6 and definitely have the Command Line Tools installed as described in the aforementioned solution (Preferences>Downloads tab>Install Command Line Tools). I do also have XCode 3.2.6 installed, however--any chance that's causing my problems?

Community
  • 1
  • 1
GChorn
  • 1,267
  • 1
  • 19
  • 36
  • Can you try the suggestions given in this post and see if the problem persists? http://stackoverflow.com/questions/5944228/python-build-using-wrong-version-of-gcc-on-os-x – Nilanjan Basu Mar 03 '13 at 10:25
  • @NilanjanBasu, see my edited question above for the things I've tried. – GChorn Mar 03 '13 at 13:32

1 Answers1

1

Have you tried CC="$(type -p clang)" pip install twisted? You don't necessarily need to use gcc to compile Twisted's extensions; selecting clang instead might clear up whatever weird problem seems to be infesting your gcc installation.

If that doesn't work, I would suggest un-installing any Python.org versions of Python and then possibly re-installing both the OS and Xcode, since it looks like something might have corrupted your system Python install. I have no idea how references to powerpc stuff have persisted into Mountain Lion, since Lion removed support for ppc.

Glyph
  • 31,152
  • 11
  • 87
  • 129
  • Thanks for your help! Sorry, but I'm a bit new to the command line--am I supposed to type in exactly what you have there as one command? Or is `"$(type -p clang)"` just a different option than `gcc-4.2` in the `export CC=` command? Either way I tried both and neither seems to do anything (I just get a new line that begins with a `>`). And as for re-installing OSX, do you think I would need to do a "hard" re-install, where I reformat my HD first? Or just the type of install here: http://support.apple.com/kb/PH10763?viewlocale=en_US? – GChorn Mar 06 '13 at 01:49
  • You can run the thing I said as an exact command-line (If you get a `>` prompt, you forgot a closing quote); it's just a way to put the `clang` that's on your path into the `CC` variable for the duration of that one command. You could also just do `export CC=clang` and it would do mostly the same thing. – Glyph Mar 07 '13 at 03:45
  • As for the reinstall, I think a regular reinstall should be fine, but I can't guess what's gone wrong with your C compiler installation; I've never seen this exact problem before. – Glyph Mar 07 '13 at 03:46