18 Jul 22:00
Re: Problems on Installing New Fipy
From: Zhiwen Liang <lzwpurdue@...>
Subject: Re: Problems on Installing New Fipy
Newsgroups: gmane.comp.python.fipy
Date: 2008-07-18 20:00:07 GMT
Subject: Re: Problems on Installing New Fipy
Newsgroups: gmane.comp.python.fipy
Date: 2008-07-18 20:00:07 GMT
Hi,
Thank you for all the concerns. Let's get one thing at a time. I found the reason for error of "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()".
In the 'make' function of viewers/__init__.py, after it creates a viewer for one of the variable of the list of variables passed into the function, it will delete that variable and create viewer for the next one, until the list of variables is empty. So that's what Line 102-103 in viewers/__init__.py do. It is the "remove" in Line 103 that causes the problem. For example, if I run:
from fipy import *
mesh=Grid1D(nx=5)
var=CellVariable(mesh=mesh,value=[1,2,3,4,5])
varlist=[var]
varlist.remove(var)
Then I get the error of:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/liangz/Library/Python/2.3/site-packages/FiPy-2.0a1-py2.3.egg/fipy/variables/variable.py", line 1112, in __nonzero__
return bool(self.getValue())
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
which is the same as the error for making a gistViewer.
The trace back shows that "remove" somehow uses the function of "__nonzero__" in variables/variables.py. And "var.getValue()" in that function returns a list. Taking the boolean of a list causes the error. But I am not sure why "remove" will use "__nonzero__".
I tried "vars.remove(var)" in an older version of fipy and it works fine.
I am still checking my other installation problems to see if I made some stupid mistakes.
Thanks again.
Zhiwen
On Fri, Jul 18, 2008 at 10:39 AM, Jonathan Guyer <guyer-R3+/ord2DXQ@public.gmane.org> wrote:
Python imports can be kind of tricky sometimes, which is why I asked you to report the result of
On Jul 17, 2008, at 5:30 PM, Zhiwen Liang wrote:Then I tried to find the pylab. There is only one pylab.py in my computer and it lives at the same site-packages directory as matplotlib, which is /sw/lib/python2.3/site-packages.
>>> import pylab
>>> pylab.__file__Meaning what? I don't believe it's possible to get the error "'module' object has no attribute 'ion'" without importing *something*. If `import pylab` fails, then you should have gotten a different error message from `viewers.make()`.But Jon is right, it is broken. I had trouble importing pylab.
No, it doesn't only use gistViewer. It uses the first viewer that it can find that actually works. gistViewer and gnuplotViewer failed, so it tried matplotlibViewer. I addressed that one first, because the error was easier to diagnose.What I don't understand is, matplotlib and pylab are just viewers and the example of 1D diffusion should only use gistViewer. The code tries to use gistViewer before it tries matplotlib. Right?
I don't know why your other viewers are throwing "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()". examples/diffusion/mesh1D.py does not generate that error with any of our viewers. Have you modified the example in any way? Are you running the tip of trunk/?
To determine what is the problem, please edit fipy/viewers/__init__.py and at line 108, please add
except Exception:
raise
*above* the line that says `except Exception, s` and then report back the full text of the error trace.Yes. It's one result of our switch to setuptools.Another problem I found is, after installing fipy, it creates a Fipy-2.0a1-py2.3.egg directory, instead of a single fipy directory, under the site-packages directory. But there is a fipy under Fipy-2.0a1-py2.3.egg. I can still import fipy. Is that normal?
gcc is not the problem. The Python interpreter has changed since some library was compiled against it. That's not FiPy because FiPy is not compiled. Likely candidates are PySparse, NumPy, SciPy, or any of the viewers.I tried to install fipy in another machine, but with no luck. That machine has matplotlib working properly. The message I got was "Fatal Python error: Interpreter not initialized (version mismatch?)". The gcc compiler is the same as when python was built.
RSS Feed