python-javabridge icon indicating copy to clipboard operation
python-javabridge copied to clipboard

Cannot import javabridge undefined symbol

Open ECarboni opened this issue 5 years ago • 4 comments

Hello, I am pretty new to python but I wanted to try out bioformats and I have problems importing javabridge. I use a conda enviroment on Ubuntu and I must use python 3.7. I did:

  • conda install bioformats
  • conda install -c bioconda java-jdk=8
  • conda install -c anaconda cython because I thought javabridge might need it
  • pip install javabridge If I run python -c "import javabridge" I get: Traceback (most recent call last): File "", line 1, in File "/.conda/envs/bioformats/lib/python3.7/site-packages/javabridge/init.py", line 38, in from .jutil import start_vm, kill_vm, vm, activate_awt, deactivate_awt File "/.conda/envs/bioformats/lib/python3.7/site-packages/javabridge/jutil.py", line 157, in import javabridge._javabridge as _javabridge ImportError:/ .conda/envs/bioformats/lib/python3.7/site-packages/javabridge/_javabridge.cpython-37m-x86_64-linux-gnu.so: undefined symbol: __intel_sse2_strchr

I am running out of ideas

ECarboni avatar Feb 26 '20 14:02 ECarboni

Hi, sorry about getting to this late. First of all, there's an unfortunate confusion regarding bioformats. There are two packages with that name - you should do pip install python-bioformats instead of conda install bioformats. But that is beside the point. I'm guessing it is some sort of snafu between Anaconda's compiler and the one that's the choice on your machine. See :https://stackoverflow.com/questions/49524083/importing-any-module-in-cython-file-gives-undefined-symbol-error for a similar problem.

I would try the following:

conda create -n bioformats openjdk python=3.7 numpy cython
conda activate bioformats
CC=gcc pip install javabridge
pip install python-bioformats

If it works, let me know and close the issue. Worked for me on Ubuntu 18.04. --Lee

LeeKamentsky avatar Feb 28 '20 13:02 LeeKamentsky

I had a similar issue to @ECarboni on OSX. Tried your install instructions @LeeKamentsky and I couldn't get it to work. Output below.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/envs/bioformats/lib/python3.7/site-packages/bioformats/__init__.py", line 21, in <module>
    import javabridge
  File "/anaconda3/envs/bioformats/lib/python3.7/site-packages/javabridge/__init__.py", line 38, in <module>
    from .jutil import start_vm, kill_vm, vm, activate_awt, deactivate_awt
  File "/anaconda3/envs/bioformats/lib/python3.7/site-packages/javabridge/jutil.py", line 157, in <module>
    import javabridge._javabridge as _javabridge
ImportError: dlopen(/anaconda3/envs/bioformats/lib/python3.7/site-packages/javabridge/_javabridge.cpython-37m-darwin.so, 2): Symbol not found: _kCFAllocatorDefault
  Referenced from: /anaconda3/envs/bioformats/lib/python3.7/site-packages/javabridge/_javabridge.cpython-37m-darwin.so
  Expected in: flat namespace
 in /anaconda3/envs/bioformats/lib/python3.7/site-packages/javabridge/_javabridge.cpython-37m-darwin.so

zacsimile avatar Mar 03 '20 16:03 zacsimile

I don't have access to a Mac and have never been able to figure out the formula for Anaconda + Javabridge on that platform. I think it has something to do with compiling using Anaconda's JDK and running using the frameworks version. I would appreciate anyone's help in this area.

LeeKamentsky avatar Mar 03 '20 19:03 LeeKamentsky

Submitted PR #173 as a fix for my (misplaced, sorry) issue.

zacsimile avatar Mar 03 '20 20:03 zacsimile