AttributeError: module 'bioformats' has no attribute 'get_omexml_metadata'

Hello everyone! (newbie here)

Environment

macOS Mojave 10.14
python-bioformats 1.5.2
Pycharm 2019.2

Context

Experimenting around with different tools. I am currently trying to create an ometiff file with 2 Series by reading and combining 2 jpg files at different resolutions.

I did install both bioformats and javabridge and my IDE recognizes them. I have an older project which uses all these tools and it works like a charm.

Problem

However in my current project when I run the code I get aforementioned error.
In Pycharm it also says this: “Cannot find reference ‘get_omexml_metadata’ in ‘init.py’”.

Here is the code:

import bioformats

import skimage
from skimage.external import tifffile


def execute(image_1, image_2):
    """ Main """

    # Get Omexml
    omexml_1 = bioformats.get_omexml_metadata(image_1)
    omexml_1 = omexml_1.encode('utf-8')
    omexml_1 = omexml_1.replace('\n      <MetadataOnly/>', '\n      <TiffData/>')

    data_1 = skimage.io.imread(image_1)
    data_2 = skimage.io.imread(image_2)

    file_name = 'temp.ome.tiff'
    with tifffile.TiffWriter(file_name) as tif:
        tif.save(data_1, photometric='minisblack', description=omexml_1, metadata={'axes': 'TZCXY'})
        tif.save(data_2, photometric='minisblack', metadata={'axes': 'TZCXY'}, contiguous=False)


if __name__ == "__main__":
    execute("input/moscow_100.jpg", "input/moscow_25.jpg")

Question

Where is the problem coming from - code, IDE, other ?

Thank you in advance for your help!

It may be that you need to enable javabridge as part of the initialisation: https://pythonhosted.org/python-bioformats/#starting-the-jvm

Thank you for the reply!

I have added the following 3 lines accordingly to my script:

import javabridge
...
javabridge.start_vm(class_path=bioformats.JARS)
...
javabridge.kill_vm()

However I still get an error of the same type:

AttributeError: module ‘bioformats’ has no attribute ‘JARS’

rather than bioformats.JARS if you point to the jar location does that solve the issue? You would need to change the location listed below:

BFPATH = r'bfpackage/bioformats_package.jar'
jars = javabridge.JARS + [BFPATH]
javabridge.start_vm(class_path=jars)

Seems I found the answer: https://github.com/LeeKamentsky/python-javabridge/issues/88

It worked before on the other project because I was using dockers, so there it ran once.
I created another image based on this current project and this time it worked.