[Ifeffit] Larch-0.9.24 with Python2

Matt Newville newville at cars.uchicago.edu
Tue Nov 4 06:41:42 CST 2014

On Tue, Nov 4, 2014 at 4:39 AM, Matthias Filez <Matthias.Filez at ugent.be> wrote:
> Dear mailing list user,
> When running an example file of Larch-0.9.24 with Python2 on Ubuntu x86_64,
> the following error was reported.
>   File "Py_usinglarch.py", line 32, in <module>
>     autobk(xafsdat.energy, xafsdat.mu, rbkg=1.0, _larch=my_larch)
>   File "/usr/local/lib/python2.7/dist-packages/larch/__init__.py", line 37,
> in wrapper
>     return fcn(*args, **keywords)
>   File "/usr/share/larch/plugins/xafs/autobk.py", line 187, in autobk
>     fit.leastsq()
>   File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py",
> line 395, in leastsq
>     lsout = leastsq(self.__residual, self.vars, **lskws)
>   File "/usr/local/lib/python2.7/dist-packages/larch/fitting/minimizer.py",
> line 222, in leastsq
>     shape, dtype = _check_func('leastsq', 'func', func, x0, args, n)
> ValueError: need more than 1 value to unpack
> Is Larch-0.9.24 compatible with Python2 on Ubuntu x86_64? If not, what
> packages and dependencies could we install to make it work on Python2? Or is
> Larch-0.9.24 only compatible with Python3?
> Many thanks in advance,
> Matthias
> _______________________________________________
> Ifeffit mailing list
> Ifeffit at millenia.cars.aps.anl.gov
> http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit

It would be helpful to post the full example script.    Larch
definitely runs with Python2 on all Linux platforms (and Windows and
Mac OSX). Testing with Python3 is minimal, and the graphics libraries
will probably need significant work to get working with Python3.

So, it *should* work. I can't tell what might be wrong just from the
traceback (perhaps there is no actual data in those arrays?).  But,
the script below does work for me.


from larch import Interpreter, use_plugin_path

from pre_edge import pre_edge
from autobk import autobk

from columnfile import _read_ascii

my_larch = Interpreter()

fname = 'examples/xafsdata/cu_rt01.xmu'

cu = _read_ascii(fname, labels='energy mu i0', _larch=my_larch)
print 'Read ASCII File:', cu
print dir(cu)

pre_edge(cu, _larch=my_larch)
print 'After pre-edge:'
print dir(cu)

autobk(cu, rbkg=1.0, kweight=1, _larch=my_larch)
# or
# autobk(cu.energy, cu.mu, group=cu, rbkg=1.0, kweight=1, _larch=my_larch)

print 'After autobk:'
print dir(cu)
print cu.chi

More information about the Ifeffit mailing list