Fiji with python scripts "Failed to install java.nio.charset.UnsupportedCharsetException: cp0

Hello,

After finding great help to develop a Jython script to analyze bulk images on Fiji, now I got weirdly stuck with the most known error: “Failed to install java.nio.charset.UnsupportedCharsetException: cp0”.

I previously run the script and it worked for most of my folders except crushing at some point and leaving some data un-analyzed. After I opened back Fiji I got the above error.

I checked everywhere online and already tried this fixing:

  • Add -Dpython.console.encoding=UTF-8 in my ImageJ.cfg file
  • Run in debug mode (duplicate the .exe and rename it as debug.exe) +/- activating the debug mode from Fiji
  • Update Java version both manually that through normal installation
  • Remove and re-install Fiji
  • Manually install another version of Jython

Nothing works and I am kind of losing hope… does anyone have any ideas? I can’t find anything online anymore.

Thanks!

Flavia

This information might help:

Hi,

Thanks I checked this as well already, the script has been kindly written by a member of this forum and already have this feature!

#@ File (label="Select a directory", style="directory") myDir
from __future__ import print_function
from ij import IJ

def main():
	root = myDir.getPath() # get the root out the java file object
	
	import os, glob

	# set up bioformats
	from loci.plugins import BF
	from loci.plugins.in import ImporterOptions
	options = ImporterOptions()
	#options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE)
	options.setGroupFiles(True)  # if the files are named logically if will group them
  	
	# this will do the maximum intensity projection
	from ij.plugin import ZProjector
	Zproj = ZProjector()

	for path, subdirs, files in os.walk(root):
		# just get the one of the files that matches your image pattern
		flist = glob.glob(os.path.join(path,"*_?.tif"))
		if( flist ):
			file = flist[0]
			print("Processing {}".format(file))
			options.setId(file)
			imp = BF.openImagePlus(options)[0]

			# show the image if you want to see it
			imp.show()

			imp_max = Zproj.run(imp,'max')
			imp_max.show()

			# save the Z projection
			IJ.save(imp_max,file.rsplit('_',1)[0]+'_processed.tif')

			# closes the windows if they are open
			imp.close()
			imp_max.close()
if( __name__ == '__builtin__'):
	main()

You advice to change the final part with "if name in [‘builtin’, ‘main’]: run_script() " ?