Skip to content
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

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

Closed
seblabbe opened this issue Jan 25, 2022 · 9 comments
Closed

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

seblabbe opened this issue Jan 25, 2022 · 9 comments

Comments

@seblabbe
Copy link
Contributor

On !MacOS 10.15.7, 8-core Core i9 2019 MacBook Pro, Justin reported the following failure https://groups.google.com/g/sage-release/c/aOpjpfOXgro/m/pxW2mRdQAwAJ :

**********************************************************************
File "src/sage/misc/latex.py", 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/forker.py", 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/forker.py", 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/latex.py", 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/__init__.py", 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/join_feature.py", 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/__init__.py", 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/imagemagick.py", 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/subprocess.py", 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/subprocess.py", 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/subprocess.py", 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/imagemagick.py was added #33092.

Component: packages: optional

Author: Sébastien Labbé

Branch/Commit: 767fb8e

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/33231

@seblabbe
Copy link
Contributor Author

comment:1

One possible solution is to put the line

result = subprocess.run(command, capture_output=True, text=True)

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

@seblabbe
Copy link
Contributor Author

Branch: u/slabbe/33231

@seblabbe
Copy link
Contributor Author

New commits:

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

@seblabbe
Copy link
Contributor Author

Commit: 767fb8e

@seblabbe

This comment has been minimized.

@seblabbe
Copy link
Contributor Author

Author: Sébastien Labbé

@seblabbe
Copy link
Contributor Author

comment:3

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'"

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 2, 2022

Reviewer: Matthias Koeppe

@vbraun
Copy link
Member

vbraun commented Feb 13, 2022

Changed branch from u/slabbe/33231 to 767fb8e

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

No branches or pull requests

3 participants