soft-matter/pims

pims Doesn't Recognize ImageIO in Conda Environment/Jupyter Notebook

jmdelahanty opened this issue · 1 comments

Hello pims developers!

I'm super excited to use the package to help us get through some videos without cutting up video data into clips unnecessarily.

I'm trying to use it in a Jupyter Notebook or on the command line but am running into an import error I can't seem to solve.

Here's what it looks like from the command line:

Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pims
/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/skimage/io/manage_plugins.py:23: UserWarning: Your installed pillow version is < 7.1.0. Several security issues (CVE-2020-11538, CVE-2020-10379, CVE-2020-10994, CVE-2020-10177) have been fixed in pillow 7.1.0 or higher. We recommend to upgrade this library.
  from .collection import imread_collection_wrapper
>>> import imageio
>>> pims.ImageIOReader("/nadata/snlkt/specialk_cs/2p/raw/CSE021/20211216/20211216_CSE021_plane1_-733.45.avi")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/pims/api.py", line 28, in raiser
    raise ImportError(
ImportError: This reader requires ImageIO.

Here's some info about my conda environment:


# packages in environment at /home/jdelahanty/miniconda3/envs/facial_expression:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                      1_llvm    conda-forge
alsa-lib                  1.2.3                h516909a_0    conda-forge
anyio                     3.5.0            py38h578d9bd_0    conda-forge
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0           py38h7f8727e_0
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py38h497a2fe_1001    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.18.1               h7f98852_0    conda-forge
ca-certificates           2021.10.8            ha878542_0    conda-forge
cairo                     1.16.0            ha12eb4b_1010    conda-forge
certifi                   2021.10.8        py38h578d9bd_2    conda-forge
cffi                      1.15.0           py38hd667e15_1
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
cloudpickle               2.0.0              pyhd8ed1ab_0    conda-forge
cryptography              35.0.0           py38ha5dfef3_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
cytoolz                   0.11.0           py38h7b6447c_0
dask-core                 2022.2.1           pyhd8ed1ab_0    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
enum34                    1.1.10           py38h32f6830_2    conda-forge
executing                 0.8.3              pyhd8ed1ab_0    conda-forge
expat                     2.4.8                h27087fc_0    conda-forge
ffmpeg                    4.3.2                h37c90e5_3    conda-forge
flit-core                 3.7.1              pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.0               h8e229c2_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freeglut                  3.2.2                h9c3ff4c_1    conda-forge
freetype                  2.10.4               h0708190_1    conda-forge
fsspec                    2022.2.0           pyhd8ed1ab_0    conda-forge
gettext                   0.19.8.1          h73d1719_1008    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
gnutls                    3.6.13               h85f3911_1    conda-forge
graphite2                 1.3.13            h58526e2_1001    conda-forge
gst-plugins-base          1.18.5               hf529b03_3    conda-forge
gstreamer                 1.18.5               h9f60fe5_3    conda-forge
harfbuzz                  3.4.0                hb4a5f5f_0    conda-forge
hdf5                      1.12.1          nompi_h2386368_104    conda-forge
icu                       69.1                 h9c3ff4c_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
imagecodecs-lite          2019.12.3        py38h5c078b8_3    conda-forge
imageio                   2.6.1                    py38_0    conda-forge
importlib-metadata        4.11.2           py38h578d9bd_0    conda-forge
importlib_resources       5.4.0              pyhd8ed1ab_0    conda-forge
ipykernel                 5.5.5            py38hd0cf306_0    conda-forge
ipython                   8.1.1            py38h578d9bd_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jasper                    2.0.33               ha77e612_0    conda-forge
jbig                      2.1               h7f98852_2003    conda-forge
jedi                      0.18.1           py38h578d9bd_0    conda-forge
jinja2                    3.0.3              pyhd8ed1ab_0    conda-forge
joblib                    1.1.0              pyhd8ed1ab_0    conda-forge
jpeg                      9d                   h7f8727e_0
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.4.0              pyhd8ed1ab_0    conda-forge
jupyter_client            7.1.2              pyhd8ed1ab_0    conda-forge
jupyter_core              4.9.2            py38h578d9bd_0    conda-forge
jupyter_server            1.13.5             pyhd8ed1ab_1    conda-forge
jupyterlab                3.3.0              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         2.10.3             pyhd8ed1ab_0    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
kiwisolver                1.3.2            py38h295c915_0
krb5                      1.19.3               h3790be6_0    conda-forge
lame                      3.100             h7f98852_1001    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
lerc                      3.0                  h9c3ff4c_0    conda-forge
libblas                   3.9.0           11_linux64_openblas    conda-forge
libcblas                  3.9.0           11_linux64_openblas    conda-forge
libclang                  13.0.1          default_hc23dcda_0    conda-forge
libcurl                   7.82.0               h7bff187_0    conda-forge
libdeflate                1.8                  h7f98852_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.10               h9b69904_4    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 11.2.0              h1d223b6_15    conda-forge
libgfortran-ng            11.2.0              h69a702a_13    conda-forge
libgfortran5              11.2.0              h5c6108e_13    conda-forge
libglib                   2.70.2               h174f98d_4    conda-forge
libglu                    9.0.0             he1b5a44_1001    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
liblapack                 3.9.0           11_linux64_openblas    conda-forge
liblapacke                3.9.0           11_linux64_openblas    conda-forge
libllvm13                 13.0.1               hf817b99_2    conda-forge
libnghttp2                1.47.0               h727a467_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.17          pthreads_h8fe5266_1    conda-forge
libopencv                 4.5.5            py38hd60e7aa_0    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libpq                     14.2                 hd57d9b9_0    conda-forge
libprotobuf               3.19.4               h780b84a_0    conda-forge
libsodium                 1.0.18               h36c2ea0_1    conda-forge
libssh2                   1.10.0               ha56f1ee_2    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_15    conda-forge
libtiff                   4.3.0                h6f004c6_2    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp-base              1.2.2                h7f98852_1    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
libxml2                   2.9.12               h885dcf4_1    conda-forge
libzlib                   1.2.11            h166bdaf_1014    conda-forge
llvm-openmp               13.0.1               he0ac6c6_1    conda-forge
locket                    0.2.0                      py_2    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
markupsafe                2.0.1            py38h497a2fe_0    conda-forge
matplotlib-base           3.3.4            py38h0efea84_0    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py38h497a2fe_1004    conda-forge
mysql-common              8.0.28               haf5c9bc_3    conda-forge
mysql-libs                8.0.28               h28c427c_3    conda-forge
nbclassic                 0.3.5              pyhd8ed1ab_0    conda-forge
nbclient                  0.5.11             pyhd8ed1ab_0    conda-forge
nbconvert                 6.4.2            py38h578d9bd_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h7f8727e_2
nest-asyncio              1.5.4              pyhd8ed1ab_0    conda-forge
nettle                    3.6                  he412f7d_0    conda-forge
networkx                  2.7                pyhd8ed1ab_0    conda-forge
notebook                  6.4.8              pyha770c72_0    conda-forge
nspr                      4.32                 h9c3ff4c_1    conda-forge
nss                       3.77                 h2350873_0    conda-forge
numpy                     1.20.3           py38h9894fe3_1    conda-forge
olefile                   0.46               pyh9f0ad1d_1    conda-forge
opencv                    4.5.5            py38h578d9bd_0    conda-forge
openh264                  2.1.1                h780b84a_0    conda-forge
openssl                   1.1.1n               h166bdaf_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.2.3            py38h51da96c_0    conda-forge
pandoc                    2.17.1.1             ha770c72_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
partd                     1.2.0              pyhd8ed1ab_0    conda-forge
pathlib                   1.0.1            py38h578d9bd_5    conda-forge
pcre                      8.45                 h9c3ff4c_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    6.2.1            py38h6b7be26_0    conda-forge
pims                      0.5                pyh9f0ad1d_1    conda-forge
pip                       21.2.4           py38h06a4308_0
pixman                    0.40.0               h36c2ea0_0    conda-forge
pooch                     1.6.0              pyhd8ed1ab_0    conda-forge
prometheus_client         0.13.1             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.27             pyha770c72_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
py-opencv                 4.5.5            py38he5a9106_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.7              pyhd8ed1ab_0    conda-forge
pyrsistent                0.18.0           py38heee7806_0
pysocks                   1.7.1            py38h578d9bd_4    conda-forge
python                    3.8.13          h582c2e5_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.8                      2_cp38    conda-forge
pytz                      2021.3             pyhd8ed1ab_0    conda-forge
pywavelets                1.1.1            py38h7b6447c_2
pyyaml                    5.4.1            py38h497a2fe_0    conda-forge
pyzmq                     19.0.2           py38ha71036d_2    conda-forge
qt                        5.12.9               ha98a1a1_5    conda-forge
readline                  8.1.2                h7f8727e_1
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
scikit-image              0.18.1           py38h51da96c_0    conda-forge
scikit-learn              0.23.2           py38h5d63f67_3    conda-forge
scipy                     1.5.3            py38hb2138dd_0    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                58.0.4           py38h06a4308_0
six                       1.16.0             pyh6c4a22f_0    conda-forge
slicerator                1.1.0              pyhd8ed1ab_0    conda-forge
sniffio                   1.2.0            py38h578d9bd_2    conda-forge
sqlite                    3.37.2               hc218d9a_0
stack_data                0.2.0              pyhd8ed1ab_0    conda-forge
terminado                 0.13.2           py38h578d9bd_0    conda-forge
testpath                  0.6.0              pyhd8ed1ab_0    conda-forge
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
tifffile                  2019.7.26.2              py38_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
toolz                     0.11.2             pyhd8ed1ab_0    conda-forge
tornado                   6.1              py38h497a2fe_1    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.8             pyhd8ed1ab_1    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          1.3.1              pyhd8ed1ab_0    conda-forge
wheel                     0.37.1             pyhd3eb1b0_0
x264                      1!161.3030           h7f98852_1    conda-forge
xorg-fixesproto           5.0               h7f98852_1002    conda-forge
xorg-inputproto           2.3.2             h7f98852_1002    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.0.10               h7f98852_0    conda-forge
xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
xorg-libx11               1.7.2                h7f98852_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h7f98852_1    conda-forge
xorg-libxfixes            5.0.3             h7f98852_1004    conda-forge
xorg-libxi                1.7.10               h7f98852_0    conda-forge
xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.5                h7b6447c_0
yaml                      0.2.5                h516909a_0    conda-forge
zeromq                    4.3.4                h9c3ff4c_0    conda-forge
zipp                      3.7.0              pyhd8ed1ab_1    conda-forge
zlib                      1.2.11            h166bdaf_1014    conda-forge
zstd                      1.5.2                ha95c52a_0    conda-forge

Any advice anyone?

I fixed it! Even though ImageIO was installed, there was a dependency that ImageIO required as well. Here's what I found when messing with ImageIO on it's own:

(facial_expression) jdelahanty@cheetos:/snlkt/data/facial_expression$ python3.8
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import imageio as iio
>>> im = iio.get_reader
>>> im
<function get_reader at 0x7fdec3824790>
>>> test = iio.get_reader("/nadata/snlkt/specialk_cs/2p/raw/CSE014/20211211/20211211_CSE014_plane1_-320.375.avi")
Traceback (most recent call last):
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/imageio/plugins/ffmpeg.py", line 59, in _get_ffmpeg_api
    import imageio_ffmpeg
ModuleNotFoundError: No module named 'imageio_ffmpeg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/imageio/core/functions.py", line 186, in get_reader
    return format.get_reader(request)
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/imageio/core/format.py", line 170, in get_reader
    return self.Reader(self, request)
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/imageio/core/format.py", line 221, in __init__
    self._open(**self.request.kwargs.copy())
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/imageio/plugins/ffmpeg.py", line 257, in _open
    self._ffmpeg_api = _get_ffmpeg_api()
  File "/home/jdelahanty/miniconda3/envs/facial_expression/lib/python3.8/site-packages/imageio/plugins/ffmpeg.py", line 61, in _get_ffmpeg_api
    raise ImportError(
ImportError: To use the imageio ffmpeg plugin you need to 'pip install imageio-ffmpeg'

After doing:

(facial_expression) jdelahanty@cheetos:/snlkt/data/facial_expression$ pip install imageio-ffmpeg
Collecting imageio-ffmpeg
  Downloading imageio_ffmpeg-0.4.5-py3-none-manylinux2010_x86_64.whl (26.9 MB)
     |████████████████████████████████| 26.9 MB 162 kB/s
Installing collected packages: imageio-ffmpeg
Successfully installed imageio-ffmpeg-0.4.5

I could then get the reader! Doing it looked like this:

(facial_expression) jdelahanty@cheetos:/snlkt/data/facial_expression$ python3.8
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import imageio
>>> import pims
>>> pims.ImageIOReader
<class 'pims.imageio_reader.ImageIOReader'>
>>> pims.ImageIOReader("/nadata/snlkt/specialk_cs/2p/raw/CSE014/20211211/20211211_CSE014_plane1_-320.375.avi")
<FramesSequenceND>
Axes: 3
Axis 'x' size: 1280
Axis 'y' size: 1024
Axis 't' size: 45270
Pixel Datatype: uint8

Maybe the issue should remain open or some documentation for this being the potential reason for the exception could be added? I've never done that before, but would be happy to help if I could!