0

Having installed FiPy using pip with a brew installation of Python 2.7.3 on OSX 10.8.2, I ran the following sample test code:

from fipy import *
mesh = Grid3D(nx=50, ny=100, nz=10, dx=0.1, dy=0.01, dz=0.1)
x, y, z = mesh.cellCenters
xyzVar = CellVariable(mesh=mesh, name=r"x y z", value=x * y * z)
k = Variable(name="k", value=0.)
viewer = MayaviClient(vars=numerix.sin(k * xyzVar), limits={'ymin': 0.1, 'ymax': 0.9}, datamin=-0.9, datamax=2.0, title="MayaviClient test")
for kval in range(10):
   k.setValue(kval)
   viewer.plot()
viewer._promptForOpinion()

which generated the following error:

File "/usr/local/lib/python2.7/site-packages/pyface/qt/__init__.py", line 17, in prepare_pyqt4 
sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1

I decided to see how far I could get by commenting out sip.setapi('QString', 2) and sip.setapi('QVariant', 2) in prepare_pyqt4. This simple hack got passed the versioning issue but presented a new problem.

File "/Library/Python/2.7/site-packages/fipy/viewers/mayaviViewer/mayaviDaemon.py", line 79, in <module>
from enthought.mayavi.plugins.app import Mayavi
ImportError: No module named enthought.mayavi.plugins.app

It seems now the FiPy Mayavi viewer is lacking a module.

I think my site-packages should all be in the same location too. Looks like pip installs to /Library/Python/2.7/site-packages while brew installs to /usr/local/lib/python2.7/site-packages, something I have to fix up (I think the problem is with pip).

The question I have is how can I get a clean FiPy installation working with Mayavi (without generating these errors) and fix up my site-packages?

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Paul
  • 49
  • 1
  • 7
  • First of all, _do not_ comment out `sip.setapi` calls. You'll most probably break the module/package because it relies on that. Secondly, what else is using `PyQt`? That error happens if someone calls `sip.setapi` after PyQt modules are imported. `FiPy` doesn't look like it uses PyQt (besides Mayavi at least). Are you running this via an editor/IDE? Some editors use (therefore load PyQt). – Avaris Jan 19 '13 at 01:50
  • Thanks, I'm using Eclipse IDE with PyDev. I tried running the test code from a shell but get the same error as above. – Paul Jan 19 '13 at 09:14
  • Note that I found I could get the test code working in a shell by placing at the beginning: import sip sip.setapi('QString', 2) sip.setapi('QVariant', 2) However, in Eclipse it still gives the error: ImportError: No module named enthought.mayavi.plugins.app – Paul Jan 19 '13 at 12:10
  • Please also take a look at this: http://stackoverflow.com/questions/12182052/installing-mayavi-with-pip-no-module-named-vtk – dashesy Mar 10 '13 at 19:50

1 Answers1

0

I don't know for sure what's causing your problem. I run a Homebrew installation under Mac OS X 10.6.8 and Mayavi works for me (including your example script). I described my installation process at http://matforge.org/fipy/wiki/InstallFiPy/MacOSX/HomeBrew

The only issue I can guess is that you say your pip installs into /Library/Python/2.7/site-packages. I would guess that you are using the system python and not one installed by brew. The last time I did it, I had to brew install python and then easy_install pip, but https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python makes it sound like you get pip automatically with a brewed python, now.

Try doing

  • which python
  • which easy_install
  • which pip
jeguyer
  • 2,379
  • 1
  • 11
  • 15