probleming in getting Mathics3 working

280 views
Skip to first unread message

Rashad alsharpini2

unread,
Mar 14, 2026, 12:07:37 PMMar 14
to sage-devel

so i have install the package 
`pip install mathics3` and i get this huge error log
would this be the objective of the project 'Improve integration with Mathics'
or this an isolated error for machine because i can't really i identify the error
i thought it was a mismatch in npmath package but that didn't solve it 
and there are a problem when calling the .sage() function to convert the object to a sageobj
(sage-dev) >>>    sage [develop] pip list | grep -i mathics
Mathics_Scanner               2.0.0
Mathics3                      9.0.0
(sage-dev) >>>    sage [develop] python --version
Python 3.12.12
(sage-dev) >>>    sage [develop] which python
/home/rashad/.conda/envs/sage-dev/bin/python
(sage-dev) >>>    sage [develop]
(sage-dev) >>>    sage [develop] ./sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.9.beta7, Release Date: 2026-02-25              │
│ Using Python 3.12.12. Type "help()" for help.                      │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: from sage.interfaces.mathics import mathics
sage: mobj = mathics(x^2 - 1); mobj
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/sage/sage/src/sage/interfaces/interface.py:329, in Interface._coerce_from_special_method(self, x)
    328 try:
--> 329     return (x.__getattribute__(s))(self)
    330 except AttributeError:

File sage/structure/sage_object.pyx:979, in sage.structure.sage_object.SageObject._mathics_()

File sage/symbolic/expression.pyx:1123, in sage.symbolic.expression.Expression._interface_()

File sage/structure/sage_object.pyx:723, in sage.structure.sage_object.SageObject._interface_()

File ~/sage/sage/src/sage/interfaces/interface.py:294, in Interface.__call__(self, x, name)
    293 if isinstance(x, str):
--> 294     return cls(self, x, name=name)
    295 try:
    296     # Special methods do not and should not have an option to
    297     # set the name directly, as the identifier assigned by the
    298     # interface should stay consistent. An identifier with a
    299     # user-assigned name might change its value, so we return a
    300     # new element.

File ~/sage/sage/src/sage/interfaces/interface.py:732, in InterfaceElement.__init__(self, parent, value, is_name, name)
    731 try:
--> 732     self._name = parent._create(value, name=name)
    733 except (TypeError, RuntimeError, ValueError) as x:

File ~/sage/sage/src/sage/interfaces/interface.py:515, in Interface._create(self, value, name)
    514 name = self._next_var_name() if name is None else name
--> 515 self.set(name, value)
    516 return name

File ~/sage/sage/src/sage/interfaces/mathics.py:596, in Mathics.set(self, var, value)
    595 cmd = f'{var}={value};'
--> 596 _ = self.eval(cmd)

File ~/sage/sage/src/sage/interfaces/mathics.py:579, in Mathics.eval(self, code, *args, **kwds)
    570 """
    571 Evaluates a command inside the Mathics interpreter and returns the output
    572 in printable form.
   (...)    577     '2'
    578 """
--> 579 res = self._eval(code)
    580 if res.result == 'Null':

File ~/sage/sage/src/sage/interfaces/mathics.py:562, in Mathics._eval(self, code)
    553 """
    554 Evaluates a command inside the Mathics interpreter and returns the output
    555 as a Mathics result.
   (...)    560     <Integer: 2>
    561 """
--> 562 self._lazy_init()
    563 S = self._session

File ~/sage/sage/src/sage/interfaces/mathics.py:499, in Mathics._lazy_init(self)
    498 self._initialized = True
--> 499 self._start()

File ~/sage/sage/src/sage/interfaces/mathics.py:514, in Mathics._start(self)
    513 if not self._session:
--> 514     from mathics.session import MathicsSession
    515     from mathics.core.load_builtin import import_and_load_builtins

File ~/.conda/envs/sage-dev/lib/python3.12/site-packages/mathics/session.py:19
     17 from mathics_scanner.location import ContainerKind
---> 19 from mathics.core.definitions import Definitions
     20 from mathics.core.evaluation import Evaluation, Result

File ~/.conda/envs/sage-dev/lib/python3.12/site-packages/mathics/core/definitions.py:17
     15 from mathics_scanner.tokeniser import full_names_pattern
---> 17 from mathics.core.atoms import Integer, String
     18 from mathics.core.attributes import A_NO_ATTRIBUTES

File ~/.conda/envs/sage-dev/lib/python3.12/site-packages/mathics/core/atoms.py:50
     47 T = TypeVar("T")
---> 50 class Number(Atom, ImmutableValueMixin, NumericOperators, Generic[T]):
     51     """
     52     Different kinds of Mathics Numbers, the main built-in subclasses
     53     being: Integer, Rational, Real, Complex.
     54     """

File ~/.conda/envs/sage-dev/lib/python3.12/site-packages/mathics/core/atoms.py:119, in Number()
    117     return True
--> 119 def to_mpmath(self, precision: Optional[int] = None) -> mpmath.ctx_mp_python.mpf:
    120     """
    121     Convert self.value to an mpmath number with precision ``precision``
    122     If ``precision`` is None, use mpmath's default precision.
   (...)    127     change the implementation accordingly.
    128     """

AttributeError: module 'mpmath.ctx_mp_python' has no attribute 'mpf'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 mobj = mathics(x**Integer(2) - Integer(1)); mobj

File ~/sage/sage/src/sage/interfaces/interface.py:301, in Interface.__call__(self, x, name)
    294     return cls(self, x, name=name)
    295 try:
    296     # Special methods do not and should not have an option to
    297     # set the name directly, as the identifier assigned by the
    298     # interface should stay consistent. An identifier with a
    299     # user-assigned name might change its value, so we return a
    300     # new element.
--> 301     result = self._coerce_from_special_method(x)
    302     return result if name is None else result.name(new_name=name)
    303 except TypeError:

File ~/sage/sage/src/sage/interfaces/interface.py:331, in Interface._coerce_from_special_method(self, x)
    329     return (x.__getattribute__(s))(self)
    330 except AttributeError:
--> 331     return self(x._interface_init_())

File sage/symbolic/expression.pyx:1151, in sage.symbolic.expression.Expression._interface_init_()

TypeError: _interface_init_() takes exactly 1 positional argument (0 given)
sage:

Travis Scrimshaw

unread,
Mar 14, 2026, 8:34:12 PMMar 14
to sage-devel
It seems to me you would certainly want the interface to work in a manner that is consistent with the other interfaces.

Best,
Travis

Marc Culler

unread,
Mar 14, 2026, 11:09:32 PMMar 14
to sage-devel
You are installing an extremely out of data mathics pip package which also forces installation of versions of other packages that are not compatible with SageMath 10.9.

You should run:

 %pip install Mathics3

instead.. That works for me.

- Marc

Rashad alsharpini2

unread,
Mar 15, 2026, 7:54:19 AMMar 15
to sage-...@googlegroups.com
of course but to be honest still don't understand the problem i am facing
i can't really determine if it's my setup problem or this an existing issue in the source code itself

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sage-devel/4ea9449d-9ead-4f51-81d6-e51a0624fa29n%40googlegroups.com.

Marc Culler

unread,
Mar 15, 2026, 9:15:49 AMMar 15
to sage-devel
It is a setup problem.  You need to uninstall the pip packages that were installed with the mathics package (and the mathics package itself) and install Mathics3 instead.

- Marc

Rashad alsharpini2

unread,
Mar 15, 2026, 11:51:33 AMMar 15
to sage-devel
that's what i did and resulted and this weird problem

Dima Pasechnik

unread,
Mar 15, 2026, 12:56:06 PMMar 15
to sage-...@googlegroups.com
Have you uninstalled mathics (i.e. "pip uninstall mathics"), before
trying Mathics3 ?

There is also a potential problem that "pip install mathics" overwrote
some already installed packages, then "pip unistall" won't restore
them.
There is currently an incompatibility between mathics3 (as installed
by pip from PyPI, maybe the current development version is better),
and Sage packages sympy and mpmath.
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sage-devel/1f3136a6-dbb0-4cd4-b7f7-617888f507acn%40googlegroups.com.

Rashad alsharpini2

unread,
Mar 15, 2026, 3:00:36 PMMar 15
to sage-devel
yes i did uninstall and reinstall the package with same problem and how could i be using an out of date package i used the same thing as you wrote
(sage-dev) >>>    sage [develop] pip install mathics3
Collecting mathics3
  Using cached mathics3-9.0.0-py3-none-any.whl.metadata (4.6 kB)
Collecting Mathics-Scanner>1.4.1 (from mathics3)
  Using cached mathics_scanner-2.0.0-py3-none-any.whl.metadata (5.0 kB)
Requirement already satisfied: mpmath>=1.2.0 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.3.0)
Requirement already satisfied: numpy in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (2.3.5)
Collecting palettable (from mathics3)
  Using cached palettable-3.3.3-py2.py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: pillow>=9.2 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (12.0.0)
Collecting pint (from mathics3)
  Using cached pint-0.25.2-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: python-dateutil in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (2.9.0.post0)
Collecting Pympler (from mathics3)
  Using cached Pympler-1.1-py3-none-any.whl.metadata (3.6 kB)
Requirement already satisfied: requests in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (2.32.5)
Requirement already satisfied: scipy in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.16.3)
Requirement already satisfied: setuptools in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (80.9.0)
Collecting stopit (from mathics3)
  Using cached stopit-1.1.2-py3-none-any.whl
Collecting sympy<1.14,>=1.13 (from mathics3)
  Using cached sympy-1.13.3-py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: PyYAML in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from Mathics-Scanner>1.4.1->mathics3) (6.0.3)
Collecting chardet (from Mathics-Scanner>1.4.1->mathics3)
  Using cached chardet-7.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (7.0 kB)
Requirement already satisfied: click in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from Mathics-Scanner>1.4.1->mathics3) (8.1.8)
Collecting flexcache>=0.3 (from pint->mathics3)
  Using cached flexcache-0.3-py3-none-any.whl.metadata (7.0 kB)
Collecting flexparser>=0.4 (from pint->mathics3)
  Using cached flexparser-0.4-py3-none-any.whl.metadata (18 kB)
Requirement already satisfied: platformdirs>=2.1.0 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from pint->mathics3) (4.5.1)
Requirement already satisfied: typing-extensions>=4.0.0 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from pint->mathics3) (4.15.0)
Requirement already satisfied: six>=1.5 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from python-dateutil->mathics3) (1.17.0)
Requirement already satisfied: charset_normalizer<4,>=2 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (3.4.4)
Requirement already satisfied: idna<4,>=2.5 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (3.11)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (2.6.2)
Requirement already satisfied: certifi>=2017.4.17 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (2025.11.12)
Using cached mathics3-9.0.0-py3-none-any.whl (3.4 MB)
Using cached sympy-1.13.3-py3-none-any.whl (6.2 MB)
Using cached mathics_scanner-2.0.0-py3-none-any.whl (168 kB)
Using cached chardet-7.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (559 kB)
Using cached palettable-3.3.3-py2.py3-none-any.whl (332 kB)
Using cached pint-0.25.2-py3-none-any.whl (306 kB)
Using cached flexcache-0.3-py3-none-any.whl (13 kB)
Using cached flexparser-0.4-py3-none-any.whl (27 kB)
Using cached Pympler-1.1-py3-none-any.whl (165 kB)
Installing collected packages: stopit, sympy, Pympler, palettable, flexparser, flexcache, chardet, pint, Mathics-Scanner, mathics3
  Attempting uninstall: sympy
    Found existing installation: sympy 1.14.0
    Uninstalling sympy-1.14.0:
      Successfully uninstalled sympy-1.14.0
Successfully installed Mathics-Scanner-2.0.0 Pympler-1.1 chardet-7.1.0 flexcache-0.3 flexparser-0.4 mathics3-9.0.0 palettable-3.3.3 pint-0.25.2 stopit-1.1.2 sympy-1.13.3
(sage-dev) >>>    sage [develop] pip uninstall mathics3 mathics-scanner -y
Found existing installation: Mathics3 9.0.0
Uninstalling Mathics3-9.0.0:
  Successfully uninstalled Mathics3-9.0.0
Found existing installation: Mathics_Scanner 2.0.0
Uninstalling Mathics_Scanner-2.0.0:
  Successfully uninstalled Mathics_Scanner-2.0.0
(sage-dev) >>>    sage [develop] pip install mathics3
Collecting mathics3
  Using cached mathics3-9.0.0-py3-none-any.whl.metadata (4.6 kB)
Collecting Mathics-Scanner>1.4.1 (from mathics3)
  Using cached mathics_scanner-2.0.0-py3-none-any.whl.metadata (5.0 kB)
Requirement already satisfied: mpmath>=1.2.0 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.3.0)
Requirement already satisfied: numpy in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (2.3.5)
Requirement already satisfied: palettable in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (3.3.3)
Requirement already satisfied: pillow>=9.2 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (12.0.0)
Requirement already satisfied: pint in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (0.25.2)
Requirement already satisfied: python-dateutil in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (2.9.0.post0)
Requirement already satisfied: Pympler in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.1)
Requirement already satisfied: requests in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (2.32.5)
Requirement already satisfied: scipy in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.16.3)
Requirement already satisfied: setuptools in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (80.9.0)
Requirement already satisfied: stopit in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.1.2)
Requirement already satisfied: sympy<1.14,>=1.13 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from mathics3) (1.13.3)
Requirement already satisfied: PyYAML in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from Mathics-Scanner>1.4.1->mathics3) (6.0.3)
Requirement already satisfied: chardet in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from Mathics-Scanner>1.4.1->mathics3) (7.1.0)
Requirement already satisfied: click in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from Mathics-Scanner>1.4.1->mathics3) (8.1.8)
Requirement already satisfied: flexcache>=0.3 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from pint->mathics3) (0.3)
Requirement already satisfied: flexparser>=0.4 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from pint->mathics3) (0.4)
Requirement already satisfied: platformdirs>=2.1.0 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from pint->mathics3) (4.5.1)
Requirement already satisfied: typing-extensions>=4.0.0 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from pint->mathics3) (4.15.0)
Requirement already satisfied: six>=1.5 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from python-dateutil->mathics3) (1.17.0)
Requirement already satisfied: charset_normalizer<4,>=2 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (3.4.4)
Requirement already satisfied: idna<4,>=2.5 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (3.11)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (2.6.2)
Requirement already satisfied: certifi>=2017.4.17 in /home/rashad/.conda/envs/sage-dev/lib/python3.12/site-packages (from requests->mathics3) (2025.11.12)
Using cached mathics3-9.0.0-py3-none-any.whl (3.4 MB)
Using cached mathics_scanner-2.0.0-py3-none-any.whl (168 kB)
Installing collected packages: Mathics-Scanner, mathics3
Successfully installed Mathics-Scanner-2.0.0 mathics3-9.0.0
(sage-dev) >>>    sage [develop]

Rashad alsharpini2

unread,
Mar 15, 2026, 3:00:40 PMMar 15
to sage-devel
i believe  The issue is that Sage uses its own mpmath backend (sage.libs.mpmath.ext_main) which replaces the standard mpmath.ctx_mp_python module, but mathics3 was trying to import mpf/mpc from that module.

On Sunday, March 15, 2026 at 6:56:06 PM UTC+2 dim...@gmail.com wrote:

Michael Orlitzky

unread,
Mar 15, 2026, 3:16:52 PMMar 15
to sage-...@googlegroups.com
On 2026-03-15 11:58:52, Rashad alsharpini2 wrote:
> i believe The issue is that Sage uses its own mpmath backend
> (sage.libs.mpmath.ext_main) which replaces the standard
> mpmath.ctx_mp_python module, but mathics3 was trying to import mpf/mpc from
> that module.

This should change in the next beta:

https://github.com/sagemath/sage/pull/41728

Rashad alsharpini2

unread,
Mar 15, 2026, 4:49:20 PMMar 15
to sage-devel
thanks i was about to start working  on it and reporting  it :)

Marc Culler

unread,
Mar 16, 2026, 2:45:06 PMMar 16
to sage-devel
For whatever it is worth, I tested on ubuntu 24.04 with the pre-reelase appimage for Sage 10.9, based on 10.9.beta7 with python 3.14.  
After running  %pip install mathics3  the commands:

sage: from sage.interfaces.mathics import mathics
sage: mobj = mathics(x^2 - 1); mobj

did not produce any tracebacks.  They did produce warnings that there is no module named pkg_resources, which apparently caused some components of mathics to fail to load.  Since pkg_resources is not included in Python 3.14 it would seem that mathics doesn't completely support Python 3.14 (yet?).

- Marc

seb....@gmail.com

unread,
Mar 17, 2026, 1:46:54 PMMar 17
to sage-devel
I can confirm Marc's observation. On the other hand, I can reproduce the bug even with Mathics3 7.0.0 and Sage 10.5.beta3 (from our Docker Hub repository). This constellation is interesting since the last time I successfully tested the Mathics3 interface was with that release (for pull request 37395, which was published in 10.5.beta3).

Sebastian

seb....@gmail.com

unread,
Mar 23, 2026, 6:20:35 AMMar 23
to sage-devel
For the record: Fixed with 10.9.beta8:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.9.beta8, Release Date: 2026-03-22              │
│ Using Python 3.12.5. Type "help()" for help.                       │

└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: pip install Mathics3
Collecting Mathics3
  Downloading mathics3-9.0.0-py3-none-any.whl.metadata (4.6 kB)
...
Installing collected packages: stopit, typing-extensions, Pympler, palettable, click, Mathics-Scanner, flexparser, flexcache, pint, Mathics3
Successfully installed Mathics-Scanner-2.0.0 Mathics3-9.0.0 Pympler-1.1 click-8.3.1 flexcache-0.3 flexparser-0.4 palettable-3.3.3 pint-0.25.3 stopit-1.1.2 typing-extensions-4.15.0

[notice] A new release of pip is available: 24.2 -> 26.0.1
[notice] To update, run: pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.

sage: mobj = mathics(x^2 - 1); mobj
/home/sage/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/stopit/__init__.py:10: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
-1 + x ^ 2
sage:


Sebastian

Rashad alsharpini2

unread,
Mar 26, 2026, 11:34:29 AMMar 26
to sage-devel
(sage-dev) >>>    sage [develop] ./sage

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.9.beta8, Release Date: 2026-03-22              │
│ Using Python 3.14.3. Type "help()" for help.                       │

└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: from sage.interfaces.mathics import mathics
sage: mathics(x^2 - 1).sage()
No module named 'pkg_resources'
    Not able to load mathics.builtin.procedural. Check your installation.
    mathics.builtin loads from /home/rashad/.conda/envs/sage-dev/lib/python3.14/site-packages/mathics/core/load
No module named 'pkg_resources'
    Not able to load mathics.builtin.datentime. Check your installation.
    mathics.builtin loads from /home/rashad/.conda/envs/sage-dev/lib/python3.14/site-packages/mathics/core/load
/home/rashad/.conda/envs/sage-dev/lib/python3.14/site-packages/requests/__init__.py:113: RequestsDependencyWarning: urllib3 (2.6.3) or chardet (7.2.0)/charset_normalizer (3.4.5) doesn't match a supported version!
  warnings.warn(
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/sage/sage/src/sage/interfaces/mathics.py:430, in _mathics_sympysage_symbol(self)
    429             return False
--> 430     return SR.var(name)
    431 except ValueError:
    432     # sympy sometimes returns dummy variables
    433     # with name = 'None', str rep = '_None'
    434     # in particular in inverse Laplace and inverse Mellin transforms

File sage/symbolic/ring.pyx:882, in sage.symbolic.ring.SymbolicRing.var()

ValueError: The name "_uGlobal`x" is not a valid Python identifier.


During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)

Cell In[2], line 1
----> 1 mathics(x**Integer(2) - Integer(1)).sage()

File ~/sage/sage/src/sage/interfaces/interface.py:1104, in InterfaceElement.sage(self, *args, **kwds)
   1085 def sage(self, *args, **kwds):
   1086     """
   1087     Attempt to return a Sage version of this object.
   1088
   (...)   1102         [0 0]
   1103     """
-> 1104     return self._sage_(*args, **kwds)

File ~/sage/sage/src/sage/interfaces/mathics.py:1066, in MathicsElement._sage_(self, locals)
   1064 if hasattr(s, '_sage_'):
   1065     try:
-> 1066         return s._sage_()
   1067     except NotImplementedError:  # see :issue:`33584`
   1068         pass

File ~/sage/sage/src/sage/interfaces/sympy.py:364, in _sympysage_add(self)
    362 s = 0
    363 for x in self.args:
--> 364     s += x._sage_()
    365 return s

File ~/sage/sage/src/sage/interfaces/sympy.py:392, in _sympysage_pow(self)
    383 def _sympysage_pow(self):
    384     """
    385     EXAMPLES::
    386
   (...)    390         sage: assert x^pi^5 == (Symbol('x')**S.Pi**5)._sage_()
    391     """
--> 392     return self.args[0]._sage_()**self.args[1]._sage_()

File ~/sage/sage/src/sage/interfaces/mathics.py:435, in _mathics_sympysage_symbol(self)
    430     return SR.var(name)
    431 except ValueError:
    432     # sympy sometimes returns dummy variables
    433     # with name = 'None', str rep = '_None'
    434     # in particular in inverse Laplace and inverse Mellin transforms
--> 435     return SR.var(str(self))

File sage/symbolic/ring.pyx:882, in sage.symbolic.ring.SymbolicRing.var()

ValueError: The name "_uGlobal`x" is not a valid Python identifier.
sage: /quit
(sage-dev) >>>    sage [develop] ./sage -tp 8 --long src/sage/interfaces/mathics.py
Running doctests with ID 2026-03-24-16-28-13-862cc92a.
Git branch: develop
Git ref: 31a24ce257
Running with SAGE_LOCAL='/home/rashad/.conda/envs/sage-dev'
Using --optional=conda,pip,sage
Features to be detected: 32_bit,4ti2,benzene,bliss,buckygen,conway_polynomials,coxeter3,csdp,cvxopt,cvxopt,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_cubic_hecke,database_ellcurves,database_graphs,database_jones_numfield,database_knotinfo,dot2tex,dvipng,ecm,flatter,fpylll,fricas,gap_package_atlasrep,gap_package_design,gap_package_grape,gap_package_guava,gap_package_hap,gap_package_polenta,gap_package_polycyclic,gap_package_qpa,gap_package_quagroup,gfan,giac,glucose,graphviz,imagemagick,info,ipython,jmol,jupymake,jupyter_sphinx,kenzo,khoca,kissat,latte_int,lrcalc_python,lrslib,mathics,matroid_database,mcqd,meataxe,meson_editable,mpmath,msolve,nauty,networkx,numpy,palp,pandoc,pdf2svg,pdftocairo,pexpect,phitigra,pillow,plantri,polytopes_db,polytopes_db_4d,pplpy,primecountpy,ptyprocess,pycosat,pycryptosat,pynormaliz,pyparsing,python_igraph,regina,requests,rpy2,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.braiding,sage.libs.ecl,sage.libs.flint,sage.libs.gap,sage.libs.giac,sage.libs.homfly,sage.libs.linbox,sage.libs.m4ri,sage.libs.ntl,sage.libs.pari,sage.libs.singular,sage.misc.cython,sage.modular,sage.modules,sage.numerical.mip,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.function_field,sage.rings.number_field,sage.rings.padics,sage.rings.polynomial.pbori,sage.rings.real_double,sage.rings.real_mpfr,sage.sat,sage.schemes,sage.symbolic,sage_numerical_backends_coin,sagemath_doc_html,scipy,singular,sirocco,sloane_database,sphinx,symengine_py,sympy,tdlib,threejs,topcom
Doctesting 1 file using 8 threads.
No module named 'pkg_resources'
    Not able to load mathics.builtin.procedural. Check your installation.
    mathics.builtin loads from /home/rashad/.conda/envs/sage-dev/lib/python3.14/site-packages/mathics/core/load
No module named 'pkg_resources'
    Not able to load mathics.builtin.datentime. Check your installation.
    mathics.builtin loads from /home/rashad/.conda/envs/sage-dev/lib/python3.14/site-packages/mathics/core/load
/home/rashad/.conda/envs/sage-dev/lib/python3.14/site-packages/requests/__init__.py:113: RequestsDependencyWarning: urllib3 (2.6.3) or chardet (7.2.0)/charset_normalizer (3.4.5) doesn't match a supported version!
  warnings.warn(
src/bin/sage -t --long --warn-long 30.0 --random-seed=3414706164797258008326926394810047144 src/sage/interfaces/mathics.py
**********************************************************************
File "src/sage/interfaces/mathics.py", line 56, in sage.interfaces.mathics
Failed example:
    sobj = mobj2.sage(); sobj
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics[6]>", line 1, in <module>
        sobj = mobj2.sage(); sobj
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 379, in _sympysage_mul
        s *= x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 364, in _sympysage_add
        s += x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 58, in sage.interfaces.mathics
Failed example:
    sobj.parent()
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics[7]>", line 1, in <module>
        sobj.parent()
        ^^^^
    NameError: name 'sobj' is not defined
**********************************************************************
File "src/sage/interfaces/mathics.py", line 323, in sage.interfaces.mathics
Failed example:
    math_bessel_K(2,I)                      # optional - mathics
Expected:
    -2.5928861754911969782 + 0.18048997206696202663 I
Got:
    CompoundExpression[2.7182818284590452354 ^ (-1.0000000000000000000 internals`bessel`u$1) / internals`bessel`u$1 ^ 1.0000000000000000000, internals`bessel`While[True, CompoundExpression[0.50000000000000000000, (-1.0000000000000000000 2.7182818284590452354 ^ (-1.0000000000000000000 internals`bessel`u$1) / internals`bessel`u$1 ^ 2.0000000000000000000 - 1.0000000000000000000 2.7182818284590452354 ^ (-1.0000000000000000000 internals`bessel`u$1) / internals`bessel`u$1 ^ 1.0000000000000000000) / internals`bessel`u$1 ^ 1.0000000000000000000]], 1.7317959997692363070 - 0.37745896303183014917 I]
**********************************************************************
File "src/sage/interfaces/mathics.py", line 337, in sage.interfaces.mathics
Failed example:
    slist3 = mlist.sage(); slist3         # optional - mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uSystem`None" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics[77]>", line 1, in <module>
        slist3 = mlist.sage(); slist3         # optional - mathics
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1076, in _sage_
        return tuple([conv(i) for i in p])
                      ~~~~^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1072, in conv
        return self.parent()(i).sage()
               ~~~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1074, in _sage_
        return [conv(i) for i in p]
                ~~~~^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1072, in conv
        return self.parent()(i).sage()
               ~~~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uSystem`None" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 372, in sage.interfaces.mathics
Failed example:
    (e^x)._mathics_().sage()  # optional -- mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics[84]>", line 1, in <module>
        (e**x)._mathics_().sage()  # optional -- mathics
        ~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 510, in _sympysage_function
        args = [arg._sage_() for arg in self.args]
                ~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 374, in sage.interfaces.mathics
Failed example:
    exp(x)._mathics_().sage() # optional -- mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics[85]>", line 1, in <module>
        exp(x)._mathics_().sage() # optional -- mathics
        ~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 510, in _sympysage_function
        args = [arg._sage_() for arg in self.args]
                ~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 412, in sage.interfaces.mathics._mathics_sympysage_symbol
Failed example:
    st = mt.to_sympy(); st
Expected:
    _Mathics_User_Global`t
Got:
    _uGlobal`t
**********************************************************************
File "src/sage/interfaces/mathics.py", line 414, in sage.interfaces.mathics._mathics_sympysage_symbol
Failed example:
    _mathics_sympysage_symbol(st)
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`t" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics._mathics_sympysage_symbol[3]>", line 1, in <module>
        _mathics_sympysage_symbol(st)
        ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`t" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 416, in sage.interfaces.mathics._mathics_sympysage_symbol
Failed example:
    bool(_ == st._sage_())
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`t" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics._mathics_sympysage_symbol[4]>", line 1, in <module>
        bool(_ == st._sage_())
                  ~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`t" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 418, in sage.interfaces.mathics._mathics_sympysage_symbol
Failed example:
    type(st._sage_())
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`t" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics._mathics_sympysage_symbol[5]>", line 1, in <module>
        type(st._sage_())
             ~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`t" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 592, in sage.interfaces.mathics.Mathics.set
Failed example:
    bool(mathics('u').sage() == 2*x+e) # optional - mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.Mathics.set[1]>", line 1, in <module>
        bool(mathics('u').sage() == Integer(2)*x+e) # optional - mathics
             ~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 364, in _sympysage_add
        s += x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 379, in _sympysage_mul
        s *= x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 782, in sage.interfaces.mathics.Mathics.help
Failed example:
    print(mathics.help('Sin', long=True)) # optional - mathics
Expected:
    sine function
    <BLANKLINE>
    Attributes[Sin] = {Listable, NumericFunction, Protected}
    <BLANKLINE>
Got:
    <BLANKLINE>
      Sin[z]
        returns the sine of z.
    <BLANKLINE>
    Attributes[Sin] = {Listable, NumericFunction, Protected}
    <BLANKLINE>
**********************************************************************
File "src/sage/interfaces/mathics.py", line 788, in sage.interfaces.mathics.Mathics.help
Failed example:
    print(mathics.Factorial.__doc__)  # optional - mathics
Expected:
    factorial
    <BLANKLINE>
Got:
    compute factorial of a number
    <BLANKLINE>
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1007, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    s = m.sage(); s
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`e100" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[1]>", line 1, in <module>
        s = m.sage(); s
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1074, in _sage_
        return [conv(i) for i in p]
                ~~~~^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1072, in conv
        return self.parent()(i).sage()
               ~~~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 379, in _sympysage_mul
        s *= x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`e100" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1009, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    s[1].n()
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[2]>", line 1, in <module>
        s[Integer(1)].n()
        ^
    NameError: name 's' is not defined
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1011, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    s[3]^2
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[3]>", line 1, in <module>
        s[Integer(3)]**Integer(2)
        ^
    NameError: name 's' is not defined
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1017, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    m.sage()                      # optional - mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[5]>", line 1, in <module>
        m.sage()                      # optional - mathics
        ~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 364, in _sympysage_add
        s += x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 392, in _sympysage_pow
        return self.args[0]._sage_()**self.args[1]._sage_()
               ~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1023, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    m.sage()                          # optional - mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[7]>", line 1, in <module>
        m.sage()                          # optional - mathics
        ~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 379, in _sympysage_mul
        s *= x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 392, in _sympysage_pow
        return self.args[0]._sage_()**self.args[1]._sage_()
               ~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 364, in _sympysage_add
        s += x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 379, in _sympysage_mul
        s *= x._sage_()
             ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 510, in _sympysage_function
        args = [arg._sage_() for arg in self.args]
                ~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 392, in _sympysage_pow
        return self.args[0]._sage_()**self.args[1]._sage_()
               ~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`x" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1037, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    bla^2 - m.sage()                  # optional - mathics
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`bla" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[12]>", line 1, in <module>
        bla**Integer(2) - m.sage()                  # optional - mathics
                          ~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 392, in _sympysage_pow
        return self.args[0]._sage_()**self.args[1]._sage_()
               ~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`bla" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1044, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    mb = m.sage()
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 430, in _mathics_sympysage_symbol
        return SR.var(name)
               ~~~~~~^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`bla" is not a valid Python identifier.


    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[14]>", line 1, in <module>
        mb = m.sage()
      File "/home/rashad/sage/sage/src/sage/interfaces/interface.py", line 1104, in sage
        return self._sage_(*args, **kwds)
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 1066, in _sage_
        return s._sage_()
               ~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/sympy.py", line 392, in _sympysage_pow
        return self.args[0]._sage_()**self.args[1]._sage_()
               ~~~~~~~~~~~~~~~~~~~^^
      File "/home/rashad/sage/sage/src/sage/interfaces/mathics.py", line 435, in _mathics_sympysage_symbol
        return SR.var(str(self))
               ~~~~~~^^^^^^^^^^^
      File "sage/symbolic/ring.pyx", line 882, in sage.symbolic.ring.SymbolicRing.var
    ValueError: The name "_uGlobal`bla" is not a valid Python identifier.
**********************************************************************
File "src/sage/interfaces/mathics.py", line 1047, in sage.interfaces.mathics.MathicsElement._sage_
Failed example:
    bla^2 - mb
Exception raised:

    Traceback (most recent call last):
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 734, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/rashad/sage/sage/src/sage/doctest/forker.py", line 1158, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.interfaces.mathics.MathicsElement._sage_[16]>", line 1, in <module>
        bla**Integer(2) - mb
                          ^^
    NameError: name 'mb' is not defined
**********************************************************************
5 items had failures:
   6 of  87 in sage.interfaces.mathics
   2 of   7 in sage.interfaces.mathics.Mathics.help
   1 of   3 in sage.interfaces.mathics.Mathics.set
   8 of  18 in sage.interfaces.mathics.MathicsElement._sage_
   4 of   7 in sage.interfaces.mathics._mathics_sympysage_symbol
    [221 tests, 21 failures, 4.14s wall]
----------------------------------------------------------------------
src/bin/sage -t --long --warn-long 30.0 --random-seed=3414706164797258008326926394810047144 src/sage/interfaces/mathics.py  # 21 doctests failed
----------------------------------------------------------------------
Total time for all tests: 10.4 seconds
    cpu time: 4.1 seconds
    cumulative wall time: 4.1 seconds
Features detected for doctesting: mathics
(sage-dev) >>>    sage [develop]

seb....@gmail.com

unread,
Apr 1, 2026, 2:39:12 AM (10 days ago) Apr 1
to sage-devel
See PR #41885 for the resolution of the other interface incompatibilities.
Reply all
Reply to author
Forward
0 new messages