Skip to content

OSError: [Errno 86] Bad CPU type in executable: 'convert' on import matplotlib.animation #15399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alinabee opened this issue Oct 10, 2019 · 6 comments
Labels
Good first issue Open a pull request against these issues if there are no active ones! topic: animation
Milestone

Comments

@alinabee
Copy link

Bug report

Bug summary

import matplotlib.animation as animation crashes with error on macOS Catalina:

OSError: [Errno 86] Bad CPU type in executable: 'convert'

Code for reproduction

import matplotlib.animation as animation

Actual outcome

(python36) d-i184-9-160:~ alina$ python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 13:42:17) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.animation as animation
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/animation.py", line 737, in <module>
    class ImageMagickWriter(ImageMagickBase, MovieWriter):
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/animation.py", line 120, in wrapper
    if writerClass.isAvailable():
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/animation.py", line 730, in isAvailable
    return super().isAvailable()
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/animation.py", line 427, in isAvailable
    return shutil.which(cls.bin_path()) is not None
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/animation.py", line 724, in bin_path
    binpath = mpl._get_executable_info('magick').executable
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/__init__.py", line 384, in _get_executable_info
    return impl([path, "--version"], r"^Version: ImageMagick (\S*)")
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/site-packages/matplotlib/__init__.py", line 324, in impl
    args, stderr=subprocess.STDOUT, universal_newlines=True)
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/Users/alina/anaconda3/envs/python36/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 86] Bad CPU type in executable: 'convert'

Expected outcome
Expect to load library with no error.

Matplotlib version

  • Operating system: Latest Mac version (likely the culprit) -- MacOS Catalina V10.15
  • Matplotlib version: 3.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: Python 3.7.3 & Python 3.6.9 :: Anaconda, Inc.
  • Jupyter version (if applicable): N/A
  • Other libraries:

Matplotlib was installed using conda default channel

@ImportanceOfBeingErnest
Copy link
Member

Concerning the concrete issue here, I have no idea if this is due to a broken ImageMagick install, another application shadowing convert (as we have in windows) or a specific issue with MacOS Catalina.

However, in general this points to a problem with finding the available writers: I suppose we would want to catch OSError in

except FileNotFoundError as _fnf:

as well? As for availability it's not really important if the file is not there, or cannot be run, right?

More logging info from

except mpl.ExecutableNotFoundError:
# May be raised by get_executable_info.
return False
wouldn't hurt either?!

That is, I would say whatever strange things might happen trying to find available movie writers, the module should load just fine and spill out any strange encounters into the log.

@alinabee
Copy link
Author

Thanks for the assistance. Turns out my "convert" executable was not working:

Alinas-MacBook-Pro:~ alina$ convert
-bash: /usr/local/bin/convert: Bad CPU type in executable

I reinstalled ImageMagick through homebrew, but that didn't fix the "convert" executable.

The solution was to simply remove the file "convert" from /usr/local/bin, and now matplotlib works fine.

@anntzer
Copy link
Contributor

anntzer commented Oct 10, 2019

As mentioned by @ImportanceOfBeingErnest we should catch OSError, not FNFError here.

@anntzer anntzer reopened this Oct 10, 2019
@anntzer anntzer added the Good first issue Open a pull request against these issues if there are no active ones! label Oct 10, 2019
@dopplershift
Copy link
Contributor

For future googlers, the problem with convert here is that macOS Catalina dropped support for 32-bit executables.

@immaxchen
Copy link
Contributor

Hi @anntzer , can I take this issue? I'm new to open source. 😁

@jklymak
Copy link
Member

jklymak commented Oct 12, 2019

@immaxchen New contributors always welcome. Please check out the developer's guide in the docs.

tacaswell added a commit that referenced this issue Oct 13, 2019
…err-issue-15399

FIX: catch OSError instead of FileNotFoundError in _get_executable_info 

closes #15399
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this issue Oct 13, 2019
tacaswell added a commit that referenced this issue Oct 13, 2019
…413-on-v3.2.x

Backport PR #15413 on branch v3.2.x (catch OSError instead of FileNotFoundError in _get_executable_info to resolve #15399)
@QuLogic QuLogic modified the milestones: v3.3.0, v3.2.0 Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Open a pull request against these issues if there are no active ones! topic: animation
Projects
None yet
Development

No branches or pull requests

7 participants