Installing an ImageJ Python Script

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

Installing an ImageJ Python Script

Alex-2
All,
Forgive my basic questions but this is the first time I've built a python ImageJ script.  I asked a few related questions previously but I'm still having difficulty.  My preference is to use the script with ImageJ 1.x but can use Fiji if required. 

I am trying to use the script with ImageJ 1.x by placing it in the plugins folder.  The script appears in the plugins menu but when I try to run it I get an error that it can't find __future__

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named __future__
 
This makes no sense to me as the __future__ module is being used to import the with_statement module and python version is listed as :

2.5.4rc1 (2.5:723492dbab02, Feb 8 2013, 10:13:55)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]
from __future__ import with_statement is specifically designed for use with Python versions 2.5.x

https://docs.python.org/3/library/__future__.html
So ... moving on ...

I tired to use Fiji instead since it is based on ImageJ2. 

I'm able to paste the code into the Script Editor using File > New > Script ...

The code runs when executed from there.  However, when saved I can't get it to show up in the plugins menu.  I've tried saving it to :
Fiji/plugins
Fiji/plugins/Scripts
 Fiji/plugins/Scripts/Plugins
The file name has an _ in it.
The version of Fiji I'm running is ImageJ 2.0.0-rc-68/1.52e / Java1.8.0_172 (64-bit)
The version of ImageJ 1.x I'm running is ImageJ 1.52e / Java1.8.0_172 (64-bit)
Any help would be greatly appreciated.
Thanks
Alex

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Installing an ImageJ Python Script

Curtis Rueden
Hi all,

This question was cross-posted on StackOverflow [1]. I responded [2]:

> The canonical place to put scripts for ImageJ2 is
> scripts/Foo/Bar/My_Script.py, if you want it located in the menu at
> Foo > Bar > My Script.
>
> It also works for backwards compatibility to use plugins or
> plugins/Scripts. However, there was recently a critical bug preventing
> scripts from appearing in the plugins-based locations; see this thread
> [3]. The bug is fixed but not yet deployed to the core update site.

I do not know if __future__ is intended to work via ImageJ 1.x's Jython
support.

Regards,
Curtis

[1] https://stackoverflow.com/q/51575484
[2] https://stackoverflow.com/a/51601648
[3] http://forum.imagej.net/t/missing-plugins-menu-item/11888


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


On Fri, Jul 27, 2018 at 4:36 PM, Alex <
[hidden email]> wrote:

> All,
> Forgive my basic questions but this is the first time I've built a python
> ImageJ script.  I asked a few related questions previously but I'm still
> having difficulty.  My preference is to use the script with ImageJ 1.x but
> can use Fiji if required.
>
> I am trying to use the script with ImageJ 1.x by placing it in the plugins
> folder.  The script appears in the plugins menu but when I try to run it I
> get an error that it can't find __future__
>
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> ImportError: No module named __future__
>
> This makes no sense to me as the __future__ module is being used to import
> the with_statement module and python version is listed as :
>
> 2.5.4rc1 (2.5:723492dbab02, Feb 8 2013, 10:13:55)
> [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]
> from __future__ import with_statement is specifically designed for use
> with Python versions 2.5.x
>
> https://docs.python.org/3/library/__future__.html
> So ... moving on ...
>
> I tired to use Fiji instead since it is based on ImageJ2.
>
> I'm able to paste the code into the Script Editor using File > New >
> Script ...
>
> The code runs when executed from there.  However, when saved I can't get
> it to show up in the plugins menu.  I've tried saving it to :
> Fiji/plugins
> Fiji/plugins/Scripts
>  Fiji/plugins/Scripts/Plugins
> The file name has an _ in it.
> The version of Fiji I'm running is ImageJ 2.0.0-rc-68/1.52e /
> Java1.8.0_172 (64-bit)
> The version of ImageJ 1.x I'm running is ImageJ 1.52e / Java1.8.0_172
> (64-bit)
> Any help would be greatly appreciated.
> Thanks
> Alex
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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