I'm an extremely amateur programmer; I've done some recreational algorithmics programming, but I honestly have no idea how libraries and programming languages really fit together. I'm supposed to work on a project that requires some image processing, so I've been trying to install PIL for a while, but I haven't been able to.
I went to http://www.pythonware.com/products/pil/ and downloaded "Python Imaging Library 1.1.6 Source Kit (all platforms) (440k TAR GZ) (December 3, 2006)". Then I opened the folder in my command prompt and ran
$ python setup.py build_ext -i .
This was the output I got:
running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe -DHAVE_LIBZ -IlibImaging -I/opt/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _imaging.c -o build/temp.macosx-10.5-i386-2.5/_imaging.o
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
"import Image" produced an error when I tried it.
Do you guys have any idea what's going on? I'm using a MacBook Pro with a Core 2 Duo.
And I'm honestly sorry if this is ridiculously stupid.
Actually, assuming you're still using the default 2.5.x Python that comes with OS X (at least as of 10.5.6), there's a pre-built installer package for it (download the dmg for PIL).
Otherwise, you'll need to either build it from source -- which does require the mac dev tools -- or install it with MacPorts or fink
edit: mono makes a good point, you'll still need the dev tools unless you use the pre-built installer.
You need to install the developer tools that come on your Mac OS X install DVD.
GCC is the GNU compiler. It's a very useful thing to have. You just need to install it in whatever mac-friendly way exists.
http://www.tech-recipes.com/rx/726/mac-os-x-install-gcc-compiler/
So this is from awhile ago, but I just ran into the problem.
The issues lies with ->
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py
or wherever your python install is.
there is a line that sets the compile flags:
archflags = '-arch i386 -arch ppc -arch x86_64'
I just removed it from that line and went on my merry way. Now there is obviously a way to configure this from the line above:
os.environ['ARCHFLAGS']
but I don't know about that, and didn't want to mess with it.
Related
I'm trying to install Distance for python on my mac (OS X Yosemite).
After downloading the package and unpacking it, I run (as described on their page):
python setup.py install --with-c
From this I get the following error message:
running build_ext
building 'distance.cdistance' extension
gcc -fno-strict-aliasing -I/Users/me/anaconda/envs/name/include - arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/me/anaconda/envs/name/include/python2.7 -c cdistance/distance.c -o build/temp.macosx-10.5-x86_64-2.7/cdistance/distance.o
gcc -bundle -undefined dynamic_lookup -L/Users/me/anaconda/envs/name/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/cdistance/distance.o -L/Users/me/anaconda/envs/name/lib -o build/lib.macosx-10.5-x86_64-2.7/distance/cdistance.so
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
From what I understood from several posts like this one or this previously asked question, it looks like clang, which is called through the command gcc, can't find the libgcc library.
I ran find /usr/ -name libgcc*and this if what I get:
/usr//lib/libgcc_s.1.dylib
/usr//lib/libgcc_s.10.4.tbd
/usr//lib/libgcc_s.10.5.tbd
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin14.4.0/5.2.0/i386/libgcc.a
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin14.4.0/5.2.0/i386/libgcc_eh.a
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin14.4.0/5.2.0/libgcc.a
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin14.4.0/5.2.0/libgcc_eh.a
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/libgcc_ext.10.4.dylib
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/libgcc_ext.10.5.dylib
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/libgcc_s.1.dylib
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/libgcc_s_ppc64.1.dylib
/usr//local/Cellar/gcc/5.2.0/lib/gcc/5/libgcc_s_x86_64.1.dylib
/usr//local/gfortran/lib/gcc/x86_64-apple-darwin14/5.1.0/i386/libgcc.a
/usr//local/gfortran/lib/gcc/x86_64-apple-darwin14/5.1.0/i386/libgcc_eh.a
/usr//local/gfortran/lib/gcc/x86_64-apple-darwin14/5.1.0/libgcc.a
/usr//local/gfortran/lib/gcc/x86_64-apple-darwin14/5.1.0/libgcc_eh.a
/usr//local/gfortran/lib/libgcc_ext.10.4.dylib
/usr//local/gfortran/lib/libgcc_ext.10.5.dylib
/usr//local/gfortran/lib/libgcc_s.1.dylib
/usr//local/gfortran/lib/libgcc_s_ppc64.1.dylib
/usr//local/gfortran/lib/libgcc_s_x86_64.1.dylib
And now I'm stuck because I don't know what to do next. Basically the question is: how do I make clang to know where the library is ?
I solved the issue thanks to this link which showed that this is a very recent issue with Xcode6.
You just need to upgrade Xcode to Xcode7 and set it up as your default toolkit chain. Easy.
I have installed python-2.7-macosx10.5.dmg from python.org on Mac os x 10.5.8.
I'm issuing: python setup.py build for pyPortMidi-0.0.3
And getting:
Found darwin (OS X) platform
running build
running build_ext
pyrexc pypm.pyx --> pypm.c
/Users/baz/Downloads/pyPortMidi-0.0.3/pypm.pyx:357:21: Type 'PmError' not acceptable as a boolean
building 'pypm' extension
creating build/temp.macosx-10.5-intel-2.7
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -O3 -arch i386 -arch x86_64 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pypm.c -o build/temp.macosx-10.5-intel-2.7/pypm.o
pypm.c:1:2: error: #error Do not use this file, it is the result of a failed Pyrex compilation.
pypm.c:1:2: error: #error Do not use this file, it is the result of a failed Pyrex compilation.
lipo: can't figure out the architecture type of: /var/folders/oO/oO1flrWgHAC8u6KdoO0Wq++++TI/-Tmp-//ccTcgy0s.out
error: command 'gcc-4.0' failed with exit status 1
Can anyone help me to resolve this?
I found the easiest way was to build the version of pyPortMidi included in pygame, which has some fixes applied.
You can use the following pattern to import it at the top of your file, preferring the standard version, but falling back to the pygame bundled version.
try:
import pypm
except ImportError:
from pygame import pypm
Using MacPorts, it was easy to install using:
port install py27-game +portmidi
I don't know if you need something special to include portmidi in the build if you build by other methods.
Looking at the link below it seems that stuff is broken and missing. Don't know if they are going to fix it anytime soon... Been bothering me too for some time...
https://groups.google.com/forum/#!topic/pygame-mirror-on-google-groups/sf3I8Q-wYQA
I want to run python's ndimage to do some image analysis. I have a 64-bit Mac running OSX Lion and Python 2.7. When I tried to run commands from ndimage commands I found out that I need to install PIL.
I downloaded that and unzipped it (for now into the downloads folder, is there a better place to do it?). I run setup.py and get these messages:
running install
running build
running build_py
running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.6-intel-2.7/_imaging.o
unable to execute gcc-4.2: No such file or directory
error: command 'gcc-4.2' failed with exit status 1
I read Failed to build PIL on Mac OS X 10.7 Lion and made sure that I have the 32/64 bit version of python 2.7 installed (Mac OS X 64-bit/32-bit x86-64/i386 Installer (2.7.2) for Mac OS X 10.6 and 10.7 ). I also have Xcode installed. Am I doing something stupid here?
Edit 1:
looking further, I have found this gcc-4.2 failed with exit status 1. I've tried entering this when I get the error:
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.6-intel-2.7/_imaging.o
and I get these messages:
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
Edit 2:
I'm not sure if this is the right way to go, but I found a post on installing pil on OSX Leopard and, following its advice, got rid of the -arch i386 part of the command and entered:
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.6-intel-2.7/_imaging.o
Now I only get two errors:
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
From what I can tell at this point the program poops out and doesn't finish compiling. Can anyone help me take it from here?
https://github.com/kennethreitz/osx-gcc-installer/downloads
Download GCC for lion. It solved all the error: command 'gcc-4.2' failed with exit status 1
problems.
I have had very good success with the MacPorts Python Imaging Library (PIL), Pandas, Numpy and other numerical analysis packages on both Lion and Mountain Lion.
Recently there were some significant upgrades with gcc for integration with the latest numerical Python modules on MacPorts. Looked like a very significant effort. I recommend MacPorts unless you are determined to hash through a native install of PIL on Lion.
I had compiling problems with PIL with Mountain Lion and python 2.7. I used Pillow instead, it's a friendly PIL fork with wider platform support.
regardins your setup questions:
I use macports for python 2.7 and other open source stuff on my mac (libpng, libjpeg, etc for PILLOW)
virtualenv for creating a virtual python environment (venv will be built-in into python 3.3)
I put source code under ~/src (instead Downloads folder)
I'm trying to install PyCurl in my local environment which has python 2.7 and gcc-4.2 on OS X 10.7 Lion. I've tried doing this based on this answer Error installing PyCurl:
sudo env ARCHFLAGS="-arch x86_64" pip install pycurl
Which fails because I have gcc-4.2 installed via Xcode:
error: command 'gcc-4.0' failed with exit status 1
I've also tried downloading the source and building a setup.py (I modified this based on Problem trying to install PyCurl on Mac Snow Leopard):
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pycurl.c
This results in the same error as above. I have verified that I do indeed have gcc-4.2 and that it is linked to my /usr/bin.
I'm thinking that it will work if I compile it correctly so that it knows to use gcc-4.2 when installing instead of gcc-4.0. However, I don't know how to do this and have not found something to explain passing an argument to use a particular gcc. I want to avoid overriding system defaults if possible.
Chances are you have a 32-bit-only Python 2.7 installed on your system (possibly downloaded from python.org) which was built with gcc-4.0 and includes a PPC universal variant. Building C extension modules with these Pythons is very problematic with Xcode 4 installed (the default for 10.7 and optional for 10.6) because gcc-4.0 and PPC support have both been removed. The easiest and best long-term solution is to install a 64-bit/32-bit Python build (see the python.org download page for current releases) or simply use the Apple-supplied Python 2.7.1 (/usr/bin/python2.7) in 10.7.
Xcode4 dropped PPC support, so when I try building PIL, it throws hate:
Bens-MacBook-Air:Imaging-1.1.7 bkeating$ python setup.py build
running buildrunning build_pyrunning build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
/usr/bin/gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -I/usr/local/include/freetype2 -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.6/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c decode.c -o build/temp.macosx-10.6-universal-2.6/decode.o
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
decode.c:688: fatal error: error writing to -: Broken pipe
compilation terminated.
lipo: can't open input file: /var/folders/jW/jW0VkC8uEb4lAjcJou+OaU+++TI/-Tmp-//ccEmCpUp.out (No such file or directory)
error: command '/usr/bin/gcc-4.0' failed with exit status 1
I ran that first line, manually, and removed the -arch ppc option and it didn't report back with any errors, but rerunning the build process ignores this manual attempt. `gcc-4.0 also does not exist, I symlinked it to gcc-4.2.
I could go ahead and install Xcode3 and then 4, but I want to muck up my fresh install.
Is there anyway to tell PIL to not compile for PPC? I did a grep across the distribution but i did not find a single mention of PPC. Any ideas?
The solution has nothing to do with PIL but rather setting gcc's ARCHFLAGS:
ARCHFLAGS="-arch i386 -arch x86_64" sudo pip install PIL
ARCHFLAGS doesn't seem to get passed into sudo. I had to do
sudo -s
then ARCHFLAGS="-arch i386 -arch x86_64" pip install PIL
to make it work.
A better way to solve this issue, in my opinion, would be to edit your ~/.profile or /etc/bashrc and add the line:
export ARCHFLAGS="-arch i386 -arch x86_64"
Will save messing around with any future installations (I've just had to do this for installing lots of Perl modules in CPAN)!
Just to help others...
I had to use ARCHFLAGS="-arch x86_64" before building imaging with my Snow Leopard/XCode 4 system i.e. having "-arch i386" in their stopped it working for me.