CellProfiler / python-bioformats

Read and write life sciences file formats
Other
132 stars 46 forks source link

Unclear problem with bioformats.get_omexml_metadata #46

Open sebi06 opened 8 years ago

sebi06 commented 8 years ago

Hi guys,

I just cannot figure out what causes the problem shiwn below. Any ideas?

Sebi

Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)] on win32 In[2]: import bioformats In[3]: filename = r'c:\Users\M1SRH\Documents\Spyder_Projects_Testdata\CZI_Read\2x2_SNAP_CH=2_Z=5.czi' In[4]: omexml = bioformats.get_omexml_metadata(filename) Traceback (most recent call last): File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3066, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in omexml = bioformats.get_omexml_metadata(filename) File "C:\Anaconda\lib\site-packages\bioformats\formatreader.py", line 963, in get_omexml_metadata with ImageReader(path=path, url=url, perform_init=False) as rdr: File "C:\Anaconda\lib\site-packages\bioformats\formatreader.py", line 622, in init self.path) File "C:\Anaconda\lib\site-packages\javabridge\jutil.py", line 1680, in make_instance klass = get_env().find_class(class_name) AttributeError: 'NoneType' object has no attribute 'find_class'

LeeKamentsky commented 8 years ago

It's failing at the point where javabridge tries to access the loci.common.RandomAccessInputStream class. Most likely the bioformats jar isn't on the classpath. The following will tell you:

import javabridge
import bioformats
import os
javabridge.start_vm(class_path=bioformats.JARS)
classpath = javabridge.JClassWrapper('java.lang.System').getProperty('java.class.path')
for path in classpath.split(os.pathsep):
    print ("exists: " if os.path.isfile(path) else "missing: ") + path

exists: c:\Python27\lib\site-packages\javabridge-1.0.11_21_g881902f-py2.7-win-amd64.egg\javabridge\jars\rhino-1.7R4.jar
exists: c:\Python27\lib\site-packages\javabridge-1.0.11_21_g881902f-py2.7-win-amd64.egg\javabridge\jars\runnablequeue.jar
exists: c:\Python27\lib\site-packages\javabridge-1.0.11_21_g881902f-py2.7-win-amd64.egg\javabridge\jars\cpython.jar
exists: c:\users\leek\cpdev\python-bioformats\python-bioformats\bioformats\jars\loci_tools.jar
emmanuel-contreras commented 5 years ago

I was running into this problem and tried the code above and javabridge was on the classpath. later realized that I was trying to run the bioformats.get_image_reader after running the javabridge.kill_vm(). which produced the error above. Adding this in case anybody gets this problem.

also for the code above the print statement should be in parenthesis for 3.x print (("exists: " if os.path.isfile(path) else "missing: ") + path)