Installing PyNGL/PyNIO under MacOSX

If you plan to build and/or install PyNIO or PyNGL on a MacOSX system, you should look over these notes.

If you are using the python that came already installed on your Mac, then it is likely a "universal binary". Some users have had trouble importing PyNGL and PyNIO using a universal binary.

A universal binary is one that was built to run under multiple architectures; PyNGL and PyNIO can only be built for one architecture, which can pose a problem.

If you are trying to load PyNGL or PyNIO, and getting the following error:

ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PyNGL/fplib.so, 2): no suitable image found.
Did find:
/usr/local/lib/python2.7/site-packages/PyNGL/fplib.so: mach-o, but wrong architecture
then this means you likely have a universal python binary. You can force python to run in in a particular architecture by typing (for 32-bit):
arch -arch i386 python ngl01p.py
or, for 64-bit:
arch -arch x86_64 python ngl01p.py


You can quickly test if you have a "universal" python binary using the following UNIX command:

    file `which python`
If you get multiple lines of output like this:
  /usr/bin/python (for architecture x86_64):Mach-O 64-bit executable x86_64
  /usr/bin/python (for architecture i386):Mach-O executable i386
  /usr/bin/python (for architecture ppc7400):Mach-O executable ppc
Then you have a python binary that is universal. If the output is just one line:
  /usr/local/bin/python: Mach-O 64-bit executable x86_64
then you do not have a universal binary.


Building Python and NumPy from scratch

If you are still having problems with using PyNGL or PyNGL with your universal python binary, then consider posting your problem to the pyngl-talk email list.

Otherwise, you can build your own versions of Python and NumPy for the same architecture that matches whatever PyNIO or PyNGL binary you have.

Building and installing Python

  1. Download Python version 2.7.x (not 3.x) or earlier, from:

    http://www.python.org/download/

    The file to download will be called something like "Python 2.7.2 compressed source tarball (for Linux, Unix, or Mac OS X)".

  2. Uncompress and untar the file you just downloaded (somewhere where you have at least 175 megabytes of disk space). We will use Python 2.7.2 as an example:
      gunzip Python-2.7.2.tgz
      tar -xf Python-2.7.2.tar
    
  3. Set up your environment for building python. To make sure Python is built for one architecture only, you will need to set the CFLAGS and CXXFLAGS environment variables. In this example, we are also setting CC and CXX to make sure it uses the gcc and g++ compilers for the build:

    csh/tcsh:

      setenv CC gcc
      setenv CXX g++
      setenv CFLAGS -m64
      setenv CXXFLAGS -m64
    
    bash/sh:
      export CC=gcc
      export CXX=g++
      export CFLAGS=-m64
      export CXXFLAGS=-m64
    
  4. Run the configure program.

    This program allows you to specify where you want to install Python. We will use "/usr/local" as an example:

      cd Python-2.7.2
      ./configure --prefix=/usr/local
    
  5. Build and install Python.

    If the "./configure" command looks like it was successful, then you can complete the build of Python by typing:

      make all install
    
  6. Test that the build was successful.

    You first have to make sure this new Python is on your search path:

      which python
    
    If you had just installed Python to /usr/local, then the above command should report:
      /usr/local/bin/python
    
    If it doesn't, then you need to check your build to make sure there were no problems. Also check that /usr/local/bin is on your search path, and that it's on your path before any other paths that might contain other versions of Python:

      echo $PATH
    
    If /usr/local/bin is not on your search path, or it's not in the right place, then remedy this.

    Then, to check that the new Python was installed correctly, type:

      python -V
    
    This should report:
      Python 2.7.2
    

Building and installing NumPy

  1. Download NumPy from:

    http://sourceforge.net/projects/numpy/files/NumPy/

    The file to download will be called something like "numpy-1.6.1.tar.gz".

  2. Once you have the file, you need to uncompress and untar it (somewhere where you have about xxx megabytes of disk space):
      gunzip numpy-1.6.1.tar.gz
      tar -xf numpy-1.6.1.tar
    
  3. Install NumPy, being sure to use the Python you just built.

      cd numpy-1.6.1
      python setup.py install
    
  4. Test that the NumPy build was successful.
      python
      import numpy
      numpy.__version__
    
    This should report
      '1.6.1'
    

Build PyNGL and/or PyNIO against this Python and NumPy

You can now use one of our precompiled PyNGL or PyNIO binaries with this version of Python and NumPy, or you can build these packages from source yourself.

Please see the appropriate instructions:

Installing from precompiled binaries
Building/installing PyNIO from source
Building/installing PyNGL from source