"Cannot Import name..." error for scripts

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"Cannot Import name..." error for scripts

Cmhulbert
When I load up ImageJ new, I get "Cannot Import name io" error when using the following code:

from ij import IJ, io
import os
import trainableSegmentation as TS

This error occurs consistently every time I load ImageJ new, however it usually goes away after using ImageJ for a while. The error frequently occurs again for importing trainableSegmentation, and usually goes away after I open a WekaSegmentation window and close it out. Does anyone know why this happens, or how to stop it from giving me an error? I'm scripting in Jython, but I don't think that should be an issue here.

Best,
Caleb
Reply | Threaded
Open this post in threaded view
|

Re: "Cannot Import name..." error for scripts

ctrueden
Hi Caleb,

> When I load up ImageJ new, I get "Cannot Import name io" error when
> using the following code

Your code did not show on the mailing list—only Nabble. So for those using
email, here is the code you posted:

    from ij import IJ, io
    import os
    import trainableSegmentation as TS

Note that io is a subpackage of ij; normally you would write something like:

    from ij.io import FileInfo

And then you have access to that type.

>  it usually goes away after using ImageJ for a while.

I do not know what that would be the case; AFAIK, that import should give
an error every time.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, May 9, 2016 at 9:12 AM, Cmhulbert <[hidden email]> wrote:

> When I load up ImageJ new, I get "Cannot Import name io" error when using
> the
> following code:
>
>
>
> This error occurs consistently every time I load ImageJ new, however it
> usually goes away after using ImageJ for a while. The error frequently
> occurs again for importing trainableSegmentation, and usually goes away
> after I open a WekaSegmentation window and close it out. Does anyone know
> why this happens, or how to stop it from giving me an error? I'm scripting
> in Jython, but I don't think that should be an issue here.
>
> Best,
> Caleb
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Cannot-Import-name-error-for-scripts-tp5016368.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html