[SciPy-User] Strange installation?

josef.pktd@gmai... josef.pktd@gmai...
Thu Oct 29 20:27:02 CDT 2009


On Thu, Oct 29, 2009 at 8:36 PM, Groves, Randy <randy.groves@boeing.com> wrote:
> So – I’m a SciPy newbie, but not to Python.
>
>
>
> I’ve got a Fedora 10, with Python 2.5.2, scipy-0.7.0-2.fc10.i386 installed
> (scipy using yum).
>
>
>
> I try the following (never mind the values …):
>
>
>
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
>
> [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
>
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> import scipy
>
>>>> xnew = [1,2,3]
>
>>>> ynew = [10, 20, 25]
>
>>>> p0 = 17.0
>
>>>> fitfunc = lambda p, x: p - x
>
>>>> errfunc = lambda p, x, y: fitfunc(p, x) - y
>
>>>> p0 = 17.0
>
>>>> p1, success = scipy.optimize.leastsq(errfunc, p0, args=(xnew, ynew))
>
> Traceback (most recent call last):
>
>   File "<stdin>", line 1, in <module>
>
> AttributeError: 'module' object has no attribute 'optimize'
>
>>>>
>
>
>
> If I then run the unit tests with scipy.test(), afterwards the call to
> scipy.optimize.leastsq is just fine.
>
>
>
> dir(scipy) before and after the unit test confirms that optimize is not
> available.
>
>
>
> Just also determined that if I use:
>
>
>
> import scipy.optimize as op
>
>
>
> I can see the optimize package just fine.


That's the way to import it, I usually use

from scipy import optimize
from scipy import stats

Because scipy is pretty large and it takes time to import all of it,
subpackages are not automatically loaded. Users can just load the
subpackages on demand.

Josef




>
>
> -randy
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


More information about the SciPy-User mailing list