From finn.hansen at sund.ku.dk Tue Jan 23 04:17:21 2024 From: finn.hansen at sund.ku.dk (Finn Benned Hansen) Date: Tue, 23 Jan 2024 09:17:21 +0000 Subject: Error import openslide Message-ID: Used below to install Openslide and python3-openslide as described @ https://launchpad.net/~openslide/+archive/ubuntu/openslide: apt install software-properties-common add-apt-repository ppa:openslide/openslide # for OpenSlide: apt install openslide-tools # for OpenSlide Python: apt install python3-openslide When trying to 'import openslide' in a python 3.9.13 environment I get the following error message: ImportError Traceback (most recent call last) Input In [1], in () ----> 1 import openslide File /usr/lib/python3/dist-packages/openslide/__init__.py:31, in 27 from io import BytesIO 29 from PIL import Image, ImageCms ---> 31 from openslide import lowlevel 33 # For the benefit of library users 34 from openslide._version import __version__ # noqa: F401 module-imported-but-unused File /usr/lib/python3/dist-packages/openslide/lowlevel.py:51, in 47 import platform 49 from PIL import Image ---> 51 from . import _convert 54 def _load_library(): 55 def try_load(names): ImportError: cannot import name '_convert' from partially initialized module 'openslide' (most likely due to a circular import) (/usr/lib/python3/dist-packages/openslide/__init__.py) Seems _convert is actually named _convert.c in the current github version - do I need to have a c++ compiler installed also to get this to work? Best, Finn Benned Finn Benned Hansen G?steforsker K?benhavns Universitet Biomedicinsk Institut Blegdamsvej 3 K?benhavn N. finn.hansen at sund.ku.dk [Logo for K?benhavns Universitet] S?dan beskytter vi persondata -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 5568 bytes Desc: image001.png URL: From bgilbert+openslide at cs.cmu.edu Tue Jan 23 12:12:37 2024 From: bgilbert+openslide at cs.cmu.edu (Benjamin Gilbert) Date: Tue, 23 Jan 2024 11:12:37 -0600 Subject: Error import openslide In-Reply-To: References: Message-ID: On Tue, Jan 23, 2024 at 10:28?AM Finn Benned Hansen wrote: > Used below to install Openslide and python3-openslide as described @ > https://launchpad.net/~openslide/+archive/ubuntu/openslide: > > > When trying to ?import openslide? in a python 3.9.13 environment I get the > following error message: > > > *ImportError: cannot import name '_convert' from partially initialized > module 'openslide' (most likely due to a circular import) > (/usr/lib/python3/dist-packages/openslide/__init__.py)* > You don't say what Ubuntu version you're using, but I'd guess that you're trying to use a Python version that isn't the Ubuntu default. Is that correct? The compiled binary for openslide._convert is included in the .deb package, but because of how C extension modules work, it will only load on the Python 3.Y version it was compiled for. However, Python .debs always install into the unversioned /usr/lib/python3/dist-packages directory, not a versioned /usr/lib/python3.9, so the package import finds the pure Python code but fails to load the extension module. If you need to use a non-default version of Python, you should probably just install OpenSlide Python with pip. The upcoming OpenSlide Python 1.4.0 will include binary wheels for Linux, but for now, you'll need GCC and Python headers installed. Best, --Benjamin Gilbert -------------- next part -------------- An HTML attachment was scrubbed... URL: From finn.hansen at sund.ku.dk Wed Jan 24 09:53:02 2024 From: finn.hansen at sund.ku.dk (Finn Benned Hansen) Date: Wed, 24 Jan 2024 14:53:02 +0000 Subject: Error import openslide In-Reply-To: References: Message-ID: <0ff73c0f03d84035b42a36f2abf3e6cb@sund.ku.dk> Hi Benjamin, Thnx for your response. I am having the issue when using PaperSpace Gradient. Here the Ubuntu version info is: DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS" NAME="Ubuntu" VERSION="20.04.4 LTS (Focal Fossa)" .and python version 3.9.13 In /usr/lib/python3/dist-packages I do indeed find openslide and openslide_python-1.3.1.egg-info, and nothing similar in /usr/lib/python3.9. A subsequent pip install openslide-python does not help. Any suggestions to do this from command line? Like downgrading to python 3.8? On a couple of different platforms (hosted by a Danish university) openslide imports successfully and runs perfectly. These use Ubuntu 22.04.3 LTS x86_64 and Python 3.10.12 Best, Finn Finn Benned Hansen G?steforsker K?benhavns Universitet Biomedicinsk Institut Blegdamsvej 3 K?benhavn N. finn.hansen at sund.ku.dk [Logo for K?benhavns Universitet] S?dan beskytter vi persondata From: Benjamin Gilbert Sent: 23. januar 2024 18:13 To: Finn Benned Hansen Cc: openslide-users at lists.andrew.cmu.edu Subject: Re: Error import openslide Du f?r ikke ofte mails fra bgilbert+openslide at cs.cmu.edu. F? mere at vide om, hvorfor dette er vigtigt On Tue, Jan 23, 2024 at 10:28?AM Finn Benned Hansen > wrote: Used below to install Openslide and python3-openslide as described @ https://launchpad.net/~openslide/+archive/ubuntu/openslide: When trying to ?import openslide? in a python 3.9.13 environment I get the following error message: ImportError: cannot import name '_convert' from partially initialized module 'openslide' (most likely due to a circular import) (/usr/lib/python3/dist-packages/openslide/__init__.py) You don't say what Ubuntu version you're using, but I'd guess that you're trying to use a Python version that isn't the Ubuntu default. Is that correct? The compiled binary for openslide._convert is included in the .deb package, but because of how C extension modules work, it will only load on the Python 3.Y version it was compiled for. However, Python .debs always install into the unversioned /usr/lib/python3/dist-packages directory, not a versioned /usr/lib/python3.9, so the package import finds the pure Python code but fails to load the extension module. If you need to use a non-default version of Python, you should probably just install OpenSlide Python with pip. The upcoming OpenSlide Python 1.4.0 will include binary wheels for Linux, but for now, you'll need GCC and Python headers installed. Best, --Benjamin Gilbert -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 5568 bytes Desc: image001.png URL: From finn.hansen at sund.ku.dk Wed Jan 24 13:53:37 2024 From: finn.hansen at sund.ku.dk (Finn Benned Hansen) Date: Wed, 24 Jan 2024 18:53:37 +0000 Subject: Error import openslide In-Reply-To: <0ff73c0f03d84035b42a36f2abf3e6cb@sund.ku.dk> References: , <0ff73c0f03d84035b42a36f2abf3e6cb@sund.ku.dk> Message-ID: <16DF810F-7518-4BAA-BD4D-D0505F13BF67@sund.ku.dk> Hi again, Managed to solve the issue by conda installing openslide, pip installing openslide-python and apt-get install a missing file. The package works beautifully after being imported. Thnx for providing this great software package and for helping out so many dummies like myself:-) Best, Finn Sendt fra min iPhone Den 24. jan. 2024 kl. 15.53 skrev Finn Benned Hansen : ? Hi Benjamin, Thnx for your response. I am having the issue when using PaperSpace Gradient. Here the Ubuntu version info is: DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS" NAME="Ubuntu" VERSION="20.04.4 LTS (Focal Fossa)" .and python version 3.9.13 In /usr/lib/python3/dist-packages I do indeed find openslide and openslide_python-1.3.1.egg-info, and nothing similar in /usr/lib/python3.9. A subsequent pip install openslide-python does not help. Any suggestions to do this from command line? Like downgrading to python 3.8? On a couple of different platforms (hosted by a Danish university) openslide imports successfully and runs perfectly. These use Ubuntu 22.04.3 LTS x86_64 and Python 3.10.12 Best, Finn Finn Benned Hansen G?steforsker K?benhavns Universitet Biomedicinsk Institut Blegdamsvej 3 K?benhavn N. finn.hansen at sund.ku.dk S?dan beskytter vi persondata From: Benjamin Gilbert Sent: 23. januar 2024 18:13 To: Finn Benned Hansen Cc: openslide-users at lists.andrew.cmu.edu Subject: Re: Error import openslide Du f?r ikke ofte mails fra bgilbert+openslide at cs.cmu.edu. F? mere at vide om, hvorfor dette er vigtigt On Tue, Jan 23, 2024 at 10:28?AM Finn Benned Hansen > wrote: Used below to install Openslide and python3-openslide as described @ https://launchpad.net/~openslide/+archive/ubuntu/openslide: When trying to ?import openslide? in a python 3.9.13 environment I get the following error message: ImportError: cannot import name '_convert' from partially initialized module 'openslide' (most likely due to a circular import) (/usr/lib/python3/dist-packages/openslide/__init__.py) You don't say what Ubuntu version you're using, but I'd guess that you're trying to use a Python version that isn't the Ubuntu default. Is that correct? The compiled binary for openslide._convert is included in the .deb package, but because of how C extension modules work, it will only load on the Python 3.Y version it was compiled for. However, Python .debs always install into the unversioned /usr/lib/python3/dist-packages directory, not a versioned /usr/lib/python3.9, so the package import finds the pure Python code but fails to load the extension module. If you need to use a non-default version of Python, you should probably just install OpenSlide Python with pip. The upcoming OpenSlide Python 1.4.0 will include binary wheels for Linux, but for now, you'll need GCC and Python headers installed. Best, --Benjamin Gilbert -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 5568 bytes Desc: image001.png URL: