Opened 4 months ago

Closed 3 months ago

#33231 closed defect (fixed)

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

Reported by: slabbe Owned by:
Priority: major Milestone: sage-9.6
Component: packages: optional Keywords:
Cc: Merged in:
Authors: Sébastien Labbé Reviewers: Matthias Koeppe
Report Upstream: N/A Work issues:
Branch: 767fb8e (Commits, GitHub, GitLab) Commit: 767fb8e61149a0727d4457bd8de4ee810b625d86
Dependencies: Stopgaps:

Status badges

Description (last modified by slabbe)

On !MacOS 10.15.7, 8-core Core i9 2019 MacBook Pro, Justin reported the following failure :

File "src/sage/misc/", line 164, in sage.misc.latex.bool
Failed example:
    have_convert() # random
Exception raised:
    Traceback (most recent call last):
      File "sage/misc/cachefunc.pyx", line 996, in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:5998)
        return self.cache[k]
    KeyError: ((), ())

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/doctest/", line 694, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/doctest/", line 1088, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.misc.latex.bool[1]>", line 1, in <module>
        have_convert() # random
      File "sage/misc/cachefunc.pyx", line 1001, in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:6126)
        w = self.f(*args, **kwds)
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/misc/", line 171, in have_convert
        return ImageMagick().is_present()
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/features/", line 176, in is_present
        res = self._is_present()
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/features/", line 63, in _is_present
        test = f._is_present()
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/features/", line 466, in _is_present
        return self.is_functional()
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/features/", line 84, in is_functional
        result = run(cmd, cwd=base, capture_output=True, text=True)
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/", line 505, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/", line 951, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/Users/Sage/sage-9.5.rc4/local/var/lib/sage/venv-python3.9.9/lib/python3.9/", line 1821, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    OSError: [Errno 86] Bad CPU type in executable: 'convert'
1 item had failures:
   1 of  23 in sage.misc.latex.bool

The is_functional method in features/ was added #33092.

Change History (5)

comment:1 Changed 4 months ago by slabbe

One possible solution is to put the line

result =, capture_output=True, text=True)

inside of a try to catch OSError type of failures and return False for feature not present.

Last edited 4 months ago by slabbe (previous) (diff)

comment:2 Changed 4 months ago by slabbe

  • Authors set to Sébastien Labbé
  • Branch set to u/slabbe/33231
  • Commit set to 767fb8e61149a0727d4457bd8de4ee810b625d86
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

767fb8e33231: running the cmd inside of a try except clause

comment:3 Changed 4 months ago by slabbe

On my side, I tested the change by replacing convert by convvert in the cmd which generates such an OSError and I obtain:

sage: from sage.features.imagemagick import Convert
sage: a = Convert().is_functional()
sage: a
FeatureTestResult('convert', False)
sage: print(a.reason)
Running command "convvert -dispose Background -delay 20 -loop 0 
tmp_6spbh_52.png tmp_6spbh_52.gif" raised an OSError "[Errno 2]
No such file or directory: 'convvert'"

comment:4 Changed 4 months ago by mkoeppe

  • Reviewers set to Matthias Koeppe
  • Status changed from needs_review to positive_review

comment:5 Changed 3 months ago by vbraun

  • Branch changed from u/slabbe/33231 to 767fb8e61149a0727d4457bd8de4ee810b625d86
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.