1

I'm able to install Jython (via homebrew), configure PyCharm to use it as my interpreter, but I can't get PyCharm to import ij.

/usr/local/bin/jython -Dpython.path=/tmp/python /tmp/python/test.py
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState (file:/usr/local/Cellar/jython/2.7.1/libexec/jython.jar) to method java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Traceback (most recent call last):
  File "/tmp/python/test.py", line 1, in <module>
    import ij
ImportError: No module named ij

My goal is to be able to write ImageJ macros using an IDE and more advanced debugging tools than currently exist in the script editor. Python would be my preferred scripting language and PyCharm is my preferred IDE. Any thoughts would be greatly appreciated.

agf1997
  • 2,668
  • 4
  • 21
  • 36

1 Answers1

0

You need to configure your IDE to use a Jython interpreter, and have ij.jar on the PYTHONPATH of your project.

For the Eclipse IDE, there's a detailed explanation in this ImageJ forum post by Emanuele Martini.

The setup should be similar for PyCharm.

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
  • I've added the environment variable `PYTHONPATH` and set it to `/Applications/ImageJ/ImageJ.app/Contents/Java` in the run configuration, but that doesn't seem to do the trick – agf1997 Mar 14 '18 at 06:39