Skip to content

'import imageio' on M1 MacBook with Python 3.9 causes "MemoryError" - installed with conda/pip #665

Closed

Description

@slerman12
No description provided.

Activity

  1. changed the title [-]import image on M1 MacBook with python 3.9 causes "MemoryError" - installed with conda/pip[/-] [+]'import imageio' on M1 MacBook with python 3.9 causes "MemoryError" - installed with conda/pip[/+] on Oct 13, 2021
  2. changed the title [-]'import imageio' on M1 MacBook with python 3.9 causes "MemoryError" - installed with conda/pip[/-] [+]'import imageio' on M1 MacBook with Python 3.9 causes "MemoryError" - installed with conda/pip[/+] on Oct 13, 2021
  3. FirefoxMetzger commented on Oct 13, 2021

    @FirefoxMetzger
    Contributor

    Hi @slerman12 , could you provide the full stack trace of the MemoryError?

  4. slerman12 commented on Oct 13, 2021

    @slerman12
    Author
    Python 3.9.1rc1 | packaged by conda-forge | (default, Nov 28 2020, 22:21:58) 
    [Clang 11.0.0 ] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import imageio
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Users/samlerman/code/miniforge3/lib/python3.9/site-packages/imageio/__init__.py", line 38, in <module>
        from . import plugins
      File "/Users/samlerman/code/miniforge3/lib/python3.9/site-packages/imageio/plugins/__init__.py", line 87, in <module>
        from . import freeimage
      File "/Users/samlerman/code/miniforge3/lib/python3.9/site-packages/imageio/plugins/freeimage.py", line 13, in <module>
        from ._freeimage import fi, download, IO_FLAGS, FNAME_PER_PLATFORM  # noqa
      File "/Users/samlerman/code/miniforge3/lib/python3.9/site-packages/imageio/plugins/_freeimage.py", line 1332, in <module>
        fi = Freeimage()
      File "/Users/samlerman/code/miniforge3/lib/python3.9/site-packages/imageio/plugins/_freeimage.py", line 428, in __init__
        def error_handler(fif, message):
    MemoryError
    
  5. almarklein commented on Oct 13, 2021

    @almarklein
    Member

    I did not even realize that we were trying to load the freeimage lib by default. We probably shouldn't.

    Also, I have no idea what the plans of the freeimage devs are for providing binaries for M1.

  6. FirefoxMetzger commented on Oct 13, 2021

    @FirefoxMetzger
    Contributor

    @almarklein agreed. I think lazy-loading/lazy-importing any plugin on first use sounds like a better solution. However, I don't have a lot of free time to implement stuff at the moment.

    Do you know if freeimage is still actively maintained? Their website looks a bit dated and their last release is from a few years ago. If it isn't maintained anymore, then we may need to adjust to that.

  7. almarklein commented on Oct 18, 2021

    @almarklein
    Member

    Do you know if freeimage is still actively maintained?

    From what you say it looks like it isn't really. I recall there was a port on Github at some point.

    However, I don't have a lot of free time to implement stuff at the moment.

    Me neither. But making the import lazy is something that an outside contributor could do relatively easily:

    • Move FNAME_PER_PLATFORM and download from _freeimage.py to freeimage.py
    • In freeimage.py initialize fi and IO_FLAGS to None, and create a small function to import and set these (as globals) later.
    • Where fi is used, check if fi is None and if so call that function.

    That should do the trick.

  8. kmilos commented on Oct 18, 2021

    @kmilos
    Contributor

    Do you know if freeimage is still actively maintained?

    From what you say it looks like it isn't really. I recall there was a port on Github at some point.

    There are some commits happening, but no idea about roadmap. As far as forks go, I know WinIMerge are maintaining their own for example...

  9. slerman12 commented on Sep 29, 2022

    @slerman12
    Author

    Hi, is there still a known bug with M1 Mac? I get the following error:

    RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.

  10. FirefoxMetzger commented on Sep 29, 2022

    @FirefoxMetzger
    Contributor

    @slerman12 Your error doesn't sound like it is related to this issue. Instead, you simply didn't perform the post-install step needed to get the ffmpeg plugin. In the docs on the ffmpeg plugin you can find how to do this: https://imageio.readthedocs.io/en/stable/_autosummary/imageio.plugins.ffmpeg.html#module-imageio.plugins.ffmpeg

  11. slerman12 commented on Sep 29, 2022

    @slerman12
    Author

    The strange thing is I definitely have installed imageio-ffmpeg.

    pip install imageio-ffmpeg

    However, when I run the recommended install pip install imageio[ffmpeg], I get this error, might be a mistake:
    zsh: no matches found: imageio[ffmpeg].

  12. FirefoxMetzger commented on Sep 29, 2022

    @FirefoxMetzger
    Contributor

    @slerman12 Which version of ImageIO are you using?

  13. slerman12 commented on Sep 29, 2022

    @slerman12
    Author

    I tried the latest version and 2.9.0.

  14. slerman12 commented on Sep 29, 2022

    @slerman12
    Author

    Is it possible that it's because I installed within a conda environment?

  15. FirefoxMetzger commented on Sep 29, 2022

    @FirefoxMetzger
    Contributor

    Yes, if you install ImageIO in a conda environment and imageio-ffmpeg on a bare-metal /system default python (via pip install) then you will end up with each package being installed in a separate environment. Both ImageIO and imageio-ffmpeg are on conda-forge, so you should be able to conda install imageio imageio-ffmpeg.

  16. slerman12 commented on Sep 29, 2022

    @slerman12
    Author

    I had it installed in conda, but through pip. I uninstalled from pip, re-installed with conda, and it works. :)

  17. slerman12 commented on Sep 29, 2022

    @slerman12
    Author

    Dang. Is there any way to get it to work through pip? My school cluster seems to bug for some reason when I enable the conda-forge channel. I'm using a conda .yml file which downloads imageio and imageio-ffmpeg through pip.

  18. FirefoxMetzger commented on Sep 30, 2022

    @FirefoxMetzger
    Contributor

    Conda is something I never really picked up. My projects live either in a venv (via poetry) or bare-metal so this is, unfortunately, outside of my area of expertise. However, @anjos might know.

    @anjos The problem is that @slerman12 is installing imageio and imageio-ffmpeg through pip into a conda environment, and that imageio doesn't find the ffmpeg executable afterwards. Do you know why this could be and if there is an easy fix for it?

  19. anjos commented on Sep 30, 2022

    @anjos
    Contributor

    Likely, the base conda environment @slerman12 is installing imageio-ffmeg does not contain the ffmpeg binary. If you install ffmpeg on that environment, does that fix it?

    The conda-forge imageio-ffmpeg has a direct dependence on ffmpeg. This level of control is possible because conda/mamba can have non-Python dependencies (contrary to pip/setuptools). For pip-based installs, I guess this must be manually handled somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions