This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to setup swig for `fenics` on mac os x?

0 votes

When I tried to run demo code for python fenics, I came across this error:

Reading DOLFIN parameters from file "dolfin_parameters.xml".
*** -------------------------------------------------------------------------
*** Warning: UnitSquare has been deprecated in DOLFIN version 1.1.0.
*** The class UnitSquare has been replaced by UnitSquareMesh.
*** -------------------------------------------------------------------------

Traceback (most recent call last):
  File "d1_p2D.py", line 15, in <module>
    V = FunctionSpace(mesh, 'Lagrange', 1)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 390, in __init__
    FunctionSpaceBase.__init__(self, mesh, element, constrained_domain)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/functions/functionspace.py", line 84, in __init__
ufc_element, ufc_dofmap = jit(self._ufl_element)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 102, in jit
raise OSError, "Could not find swig installation. Pass an existing "\
OSError: Could not find swig installation. Pass an existing swig binary or install SWIG version 2.0 or higher.

I don't quite understand how to install swig for my computer.
I tried to use sudo port install swig, and I installed swig. But I still get this error.

Can you help me with this? Thank you.

closed with the note: Please send installation support requests to fenics-support@fenicsproject.org.
asked Jul 26, 2013 by eccstartup FEniCS Novice (160 points)
closed Aug 27, 2013 by Garth N. Wells

1 Answer

+1 vote
 
Best answer

The FEniCS binary already includes a copy of SWIG and it is not needed to install anything from MacPorts to run your FEniCS programs. Actually, mixing MacPorts and the FEniCS binary can result in problems like this.

Please make sure that /Applications/FEniCS.app/Contents/Resources/bin is first in your PATH variable. This should be the case if you run your program from the FEniCS terminal (found in the Applications folder) or if you source fenics.conf in a terminal as described on the installation page.

answered Jul 30, 2013 by johannr FEniCS Expert (17,350 points)
selected Jul 30, 2013 by eccstartup

Thanks for you kindness reply.

I run the .app file from the menu. And it added /Applications/FEniCS.app/Contents/Resources/bin to the start of $PATH.

The demos are downloaded from documentation page.

I still get the same problem.

=====================
PS: I can find swig in the /Applications/FEniCS.app/Contents/Resources/bin folder, version 2.0.8.

What does it mean by

OSError: Could not find swig installation. Pass an existing swig binary or install SWIG version 2.0 or higher.

I guess the problem is the dolfin_parameters.xml file which is located in the same directory as the d1_p2D.py program in the tutorial. Try to remove the two lines with parameters for swig in this file and see if that helps.

That is the key to the solution.

I removed the lines in the xml file, and it worked!

Thanks again for your help!

...