# Installing openslide-python

**URL:** <https://discourse.slicer.org/t/installing-openslide-python/24187>\
**Category:** Support\
**Created:** [July 5, 2022, 6:42pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187 "2022-07-05T18:42:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [July 5, 2022, 6:42pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/1 "2022-07-05T18:42:41Z")

</div>

I’m trying to install openslide-python via pip\_install to support reading NRRD files with @MONAI. I am getting the following error with Slicer 5.0.2 on Linux:

```auto
>>> pip_install('openslide-python')
Collecting openslide-python
  Using cached openslide-python-1.2.0.tar.gz (338 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: Pillow in ./lib/Python/lib/python3.9/site-packages (from openslide-python) (9.0.1)
Building wheels for collected packages: openslide-python
  Building wheel for openslide-python (setup.py): started
  Building wheel for openslide-python (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  � python setup.py bdist_wheel did not run successfully.
  ? exit code: 1
  ??> [16 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.9
      creating build/lib.linux-x86_64-3.9/openslide
      copying openslide/ __init__.py -> build/lib.linux-x86_64-3.9/openslide
      copying openslide/_version.py -> build/lib.linux-x86_64-3.9/openslide
      copying openslide/lowlevel.py -> build/lib.linux-x86_64-3.9/openslide
      copying openslide/deepzoom.py -> build/lib.linux-x86_64-3.9/openslide
      running build_ext
      building 'openslide._convert' extension
      creating build/temp.linux-x86_64-3.9
      creating build/temp.linux-x86_64-3.9/openslide
      /opt/rh/devtoolset-7/root/usr/bin/gcc -pthread -std=c99 -Wall -Wstrict-prototypes -fno-strict-aliasing -fwrapv -g -fPIC -I/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/lib/Python/include/python3.9 -c openslide/_convert.c -o build/temp.linux-x86_64-3.9/openslide/_convert.o
      error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for openslide-python
  Running setup.py clean for openslide-python
Failed to build openslide-python
Installing collected packages: openslide-python
  Running setup.py install for openslide-python: started
  Running setup.py install for openslide-python: finished with status 'error'
  error: subprocess-exited-with-error

  � Running setup.py install for openslide-python did not run successfully.
  ? exit code: 1
  ??> [18 lines of output]
      running install
      /home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/lib/Python/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.9
      creating build/lib.linux-x86_64-3.9/openslide
      copying openslide/ __init__.py -> build/lib.linux-x86_64-3.9/openslide
      copying openslide/_version.py -> build/lib.linux-x86_64-3.9/openslide
      copying openslide/lowlevel.py -> build/lib.linux-x86_64-3.9/openslide
      copying openslide/deepzoom.py -> build/lib.linux-x86_64-3.9/openslide
      running build_ext
      building 'openslide._convert' extension
      creating build/temp.linux-x86_64-3.9
      creating build/temp.linux-x86_64-3.9/openslide
      /opt/rh/devtoolset-7/root/usr/bin/gcc -pthread -std=c99 -Wall -Wstrict-prototypes -fno-strict-aliasing -fwrapv -g -fPIC -I/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/lib/Python/include/python3.9 -c openslide/_convert.c -o build/temp.linux-x86_64-3.9/openslide/_convert.o
      error: command '/opt/rh/devtoolset-7/root/usr/bin/gcc' failed: No such file or directory
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

� Encountered error while trying to install package.
??> openslide-python

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
WARNING: You are using pip version 22.0.3; however, version 22.1.2 is available.
You should consider upgrading via the '/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/bin/./python-real -m pip install --upgrade pip' command.
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/bin/Python/slicer/util.py", line 3431, in pip_install
    _executePythonModule('pip', args)
  File "/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/bin/Python/slicer/util.py", line 3394, in _executePythonModule
    logProcessOutput(proc)
  File "/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/bin/Python/slicer/util.py", line 3363, in logProcessOutput
    raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command '['/home/sara/Slicer_stable/Slicer-5.0.2-linux-amd64/bin/../bin/PythonSlicer', '-m', 'pip', 'install', 'openslide-python']' returned non-zero exit status 1.

```

It seems there is a gcc binary it cannot find. This is working on Windows OS with no issues. I would appreciate any advice.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [July 5, 2022, 11:39pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/2 "2022-07-05T23:39:58Z")

</div>

> [@smrolfe](#):
>
> This is working on Windows OS with no issues.

It builds the whl from source successfully? Or just not an issue on Windows because it uses the pre-built whl from PyPI?

openslide\_python-1.2.0-cp39-cp39-win\_amd64.whl

> **[openslide-python](https://pypi.org/project/openslide-python/1.2.0/)**
>
> Python interface to OpenSlide

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [July 6, 2022, 12:02am UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/3 "2022-07-06T00:02:14Z")

</div>

Are you able to successfully build on Ubuntu in regular python (not Slicer python)?

Some openslide-python issues related to building/whls on Linux.

> <https://github.com/openslide/openslide/issues/340>
>
> \## Context
> \*\*Operating system\*\* : Ubuntu18.04 running on docker
> \*\*Platform\*\* :… 64-bit x86 
> \*\*OpenSlide version\*\*: Latest
> 
> \## Details
> When I try to install openslide-python, I get
> 
> \> 1. install OpenSlide
> \> 2. pip install openslide-python
> 
> I did so because of the above instructions.
> 
> Steps
> 1. create \`openslide \`folder
> 2. \` cd openslide\`
> 3. \`wget https://github.com/openslide/openslide/releases/download/v3.4.1/openslide-3.4.1.tar.gz\`
> 4. \`tar -xvf openslide-3.4.1.tar.gz\`
> 5. \`cd openslide-3.4.1\`
> 6. \`./configure\`
> 
> \## Error message
> \`\`\`
> checking for a BSD-compatible install... /usr/bin/install -c
> checking whether build environment is sane... yes
> checking for a thread-safe mkdir -p... /bin/mkdir -p
> checking for gawk... no
> checking for mawk... mawk
> checking whether make sets $(MAKE)... yes
> checking whether make supports nested variables... yes
> checking whether make supports nested variables... (cached) yes
> checking build system type... x86\_64-unknown-linux-gnu
> checking host system type... x86\_64-unknown-linux-gnu
> checking for style of include used by make... GNU
> checking for gcc... no
> checking for cc... no
> checking for cl.exe... no
> configure: error: in \`/work/openslide-python/openslide-3.4.1':
> configure: error: no acceptable C compiler found in $PATH
> See \`config.log' for more details
> \`\`\`
> 
> I get an error at step 6.
> Am I doing something wrong?
> 
> Can you please tell me the correct installation procedure?
> 
> I have also tried the following
> \*\*Install with apt-get\*\*
> 1. \`sudo apt-get install openslide-tools\`
> 2. \`sudo apt-get install python-openslide\`
> I could not import openslide with this procedure.
> 
> \*\*Install from Local environment with brew\*\*
> \`\`\`
> ==\> Checking for dependents of upgraded formulae...
> ==\> No broken dependents found!
> \`\`\`
> 
> I'm very sorry to be so persistent. 
> Can you please tell me the correct installation procedure in detail?

> <https://github.com/openslide/openslide-python/issues/126>
>
> Hello, would the maintainers of this project be interested in building multi-pla…tform wheels? At the moment, pypi only includes the sources for \`openslide-python\`, so users require a compiler. This wouldn't be necessary with pre-compiled wheels.
> 
> I would be happy to submit a PR for this. I would plan to use https://github.com/pypa/cibuildwheel (which is maintained by the python packaging authority). Wheels could be built for linux, macos, and windows.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 6, 2022, 12:38am UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/4 "2022-07-06T00:38:14Z")

</div>

On Windows, OpenSlide Python package requires manual installation of OpenSlide binaries. I’ve implemented that in [BigImageViewer extension](https://github.com/gaoyi/SlicerBigImage/tree/main/BigImageViewer).

On Linux, you need to [install libopenslide](https://github.com/gaoyi/SlicerBigImage#Linux).

It is all somewhat hacky. It’ll be better to switch to OME-NGFF, a zarr-based big image (and transform, etc) file format.

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [July 6, 2022, 4:37am UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/5 "2022-07-06T04:37:23Z")

</div>

> [@jamesobutler](#):
>
> It builds the whl from source successfully? Or just not an issue on Windows because it uses the pre-built whl from PyPI?
> 
> openslide\_python-1.2.0-cp39-cp39-win\_amd64.whl

Yes, it looks like this is the case.

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [July 6, 2022, 4:43am UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/6 "2022-07-06T04:43:19Z")

</div>

Thanks @lassoan, given these OpenSlide build issues, I’m going to switch to another solution.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 6, 2022, 1:03pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/7 "2022-07-06T13:03:54Z")

</div>

> [@smrolfe](#):
>
> I’m going to switch to another solution

Keep us updated. Slicer will support the NGFF file format, probably using [ome-zarr](https://pypi.org/project/ome-zarr/) Python package. It would be great if you could use this format and experiment with the ome-zarr package.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 6, 2022, 1:16pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/8 "2022-07-06T13:16:21Z")

</div>

In case you didn’t see it here’s an example using the ome-zarr package. It’s pretty nice.

> <https://gist.github.com/pieper/0e7edcf70c844925ea104e07aedbe92a>

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [July 6, 2022, 5:49pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/9 "2022-07-06T17:49:49Z")

</div>

I though one of the benefits of the zarr was the support of the image pyramids. This imported file only seemed to display one of the resolution levels (as far as I can tell)?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/e/6e6978fc598c9d4bedf57f35832f76cab1392ca5.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 7, 2022, 8:15pm UTC](https://discourse.slicer.org/t/installing-openslide-python/24187/10 "2022-07-07T20:15:51Z")

</div>

> [@muratmaga](#):
>
> This imported file only seemed to display one of the resolution levels

Yes - the example is a bit arbitrary. The original dataset is multi-channel, 3D+T, and pyramid encoded and I just picked a particular resolution/timepoint/channel to display. All the other options can be exposed as we see fit, such as extracting a high-res subvolume and mapping any three channels to RGB (or a more complex mapping). The ome-zarr library supports all these options and we need to figure out a good interface for that.
