TissueImageAnalytics / tiatoolbox

Computational Pathology Toolbox developed by TIA Centre, University of Warwick.
https://warwick.ac.uk/tia
Other
374 stars 77 forks source link

Tiatoolbox stopped working after generating yml file. SSL problem with openslide? #803

Closed KenAncheta closed 5 months ago

KenAncheta commented 6 months ago

Description

I am trying to run the stain normalisation function from TIAToolbox. The functions were all running fine without any problem. However, when I was generating yml file to run TIAToolbox on another machine, suddenly the environment and ipykernel containing the TIAToolbox disappeared. When I tried to reinstall the package from scratch using the installation guide (https://tia-toolbox.readthedocs.io/en/latest/installation.html), I can't run it anymore.

What I Did

So from scratch, I uninstalled homebrew and tiatoolbox.

$ conda create -n tiatoolbox python=3.11.8
$ conda activate tiatoolbox
(tiatoolbox) $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 
(tiatoolbox) $ brew install openjpeg openslide
(tiatoolbox) $ pip install tiatoolbox
(tiatoolbox) $ python -m ipykernel install --user --name tiatoolbox --display-name "TIAToolbox (3.11.8)"
(tiatoolbox) $ python
>>> import tiatoolbox
>>> from tiatoolbox.tools.stainnorm import MacenkoNormalizer
>>> Error (please see error below)

So I tried interacting with the environment using VSCode and use tiatoolbox as kernel:

import tiatoolbox
from tiatoolbox.tools.stainnorm import MacenkoNormalizer
Error (please see below)

I also tried installing homebrew from outside of the environment. Same thing occured. 

I can't seem to use tiatoolbox anymore.

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
OSError: dlopen(libopenslide.0.dylib, 0x0006): tried: 'libopenslide.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibopenslide.0.dylib' (no such file), '/Users/username/opt/anaconda3/envs/tia/lib/python3.11/lib-dynload/../../libopenslide.0.dylib' (no such file), '/Users/username/opt/anaconda3/envs/tia/bin/../lib/libopenslide.0.dylib' (no such file), '/usr/lib/libopenslide.0.dylib' (no such file, not in dyld cache), 'libopenslide.0.dylib' (no such file), '/usr/local/lib/libopenslide.0.dylib' (no such file), '/usr/lib/libopenslide.0.dylib' (no such file, not in dyld cache)

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[6], [line 2](vscode-notebook-cell:?execution_count=6&line=2)
      [1](vscode-notebook-cell:?execution_count=6&line=1) import tiatoolbox
----> [2](vscode-notebook-cell:?execution_count=6&line=2) from tiatoolbox.tools.stainnorm import MacenkoNormalizer

ModuleNotFoundError: Couldn't locate OpenSlide dylib.  Is OpenSlide installed correctly?  https://openslide.org/api/python/#installing
Abdol commented 5 months ago

Hello @KenAncheta. Are you using a Mac running Apple Silicon? If so, you can try installing OpenSlide using conda: conda install -c conda-forge openslide and then try importing the stain normaliser again. The issue can occur due to having incompatible OpenSlide binaries (e.g., having x86_64 binaries but needing arm64/arm64e).

KenAncheta commented 5 months ago

Hi @Abdol. Yes I am using Apple Silicon Mac. When I use conda install -c conda-forge openslide, it gets stuck (code below). It's been 3 hours since I tried the installation using conda-forge.

conda install -c conda-forge openslide Retrieving notices: ...working... done Collecting package metadata (current_repodata.json): done Solving environment: / The environment is inconsistent, please check the package plan carefully The following packages are causing the inconsistency:

GeorgeBatch commented 5 months ago

I think I had a similar issue on an M1 Mac. Note: I am using Tiatoolbox, but I am not one of the core developers.

  1. I installed openslide and openjpeg inside the conda environment instead of on the machine as the very first thing after creating and activating the environment. I think you will need to uninstall the version you got via brew so only one version is available inside the tiatoolbox conda environment.
conda create -n tiatoolbox python=3.11 -y
conda activate tiatoolbox
conda install openslide openjpeg -c conda-forge
  1. Updating conda through updating Miniconda distribution (https://docs.anaconda.com/free/miniconda/#quick-command-line-install) helped speed up solving environments.
KenAncheta commented 5 months ago

@GeorgeBatch This solution worked for me! Thanks!