mathics-core icon indicating copy to clipboard operation
mathics-core copied to clipboard

Support for Python 3.12

Open gujunhk opened this issue 2 years ago • 2 comments

"distutils" has been removed in Python 3.12 and Mathics3 will throw an error that no module named 'disutils'.

Officially support is needed.

gujunhk avatar Oct 23 '23 02:10 gujunhk

Thanks for the report. Is this something you would be interested in working on?

(I imagine this kind of thing does not require much special knowledge of the code, but is more of a general programming administration kind of thing.)

rocky avatar Oct 23 '23 03:10 rocky

#978 starts with this work. The main problem is an undocumented change in how the recursion limit is fixed.

mmatera avatar Jan 26 '24 03:01 mmatera

Here's some other error that already appears with python 3.10:

pip install mathics
$ mathics
Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/mathics", line 5, in <module>
    from mathics.main import main
  File "/home/ubuntu/.local/lib/python3.10/site-packages/mathics/__init__.py", line 10, in <module>
    import sympy
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/__init__.py", line 49, in <module>
    from .polys import *
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/polys/__init__.py", line 5, in <module>
    from . import polytools
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/polys/polytools.py", line 19, in <module>
    from sympy.polys.polyclasses import DMP
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/polys/polyclasses.py", line 104, in <module>
    from sympy.polys.euclidtools import (
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/polys/euclidtools.py", line 41, in <module>
    from sympy.polys.galoistools import (
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/polys/galoistools.py", line 14, in <module>
    from sympy.ntheory import factorint
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/ntheory/__init__.py", line 20, in <module>
    from .egyptian_fraction import egyptian_fraction
  File "/home/ubuntu/.local/lib/python3.10/site-packages/sympy/ntheory/egyptian_fraction.py", line 6, in <module>
    from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)

https://stackoverflow.com/questions/66174862/import-error-cant-import-name-gcd-from-fractions

Masterxilo avatar Jul 20 '24 15:07 Masterxilo

Here's some other error that already appears with python 3.10:

pip install mathics

mathics is the older version. It is no longer maintained; mathics3 is the newer version, but we haven't put out a new release for it in a while. (This has been on my mind and will probably do soonish.)

So in the meantime install from source code:

$ cd Mathics3/mathics-core
$ pip install -e . 
pip install -e . 
Obtaining file:///tmp/Mathics3/mathics-core
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
...

$ mathics
mathics
/tmp/Mathics3/mathics-core/mathics/builtin/files_io/importexport.py:3: SyntaxWarning: invalid escape sequence '\M'
  """

Mathics 7.0.0dev0
on CPython 3.12.3 (main, May  6 2024, 11:37:55) [GCC 13.2.0]
using SymPy 1.13.1, mpmath 1.3.0, numpy 1.26.4, cython Not installed

Copyright (C) 2011-2023 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.

Quit by evaluating Quit[] or by pressing CONTROL-D.

In[1]:= 1+2
1+2
Out[1]= 3

rocky avatar Jul 20 '24 16:07 rocky

I tried a fresh installation of version 7.0.0 and encountered the following messages (the following log was with Python 3.10 but the same with Python 3.12):

pip install mathics3
mathics
No module named 'packaging'
    Not able to load mathics.builtin.numbers.numbertheory. Check your installation.
    mathics.builtin loads from /home/tueda/tmp/.venv/lib/python3.10/site-packages/mathics/core/load

    Not able to load mathics.builtin.scipy_utils.integrators. Check your installation.
    mathics.builtin loads from /home/tueda/tmp/.venv/lib/python3.10/site-packages/mathics/core/load

    Not able to load mathics.builtin.scipy_utils.optimizers. Check your installation.
    mathics.builtin loads from /home/tueda/tmp/.venv/lib/python3.10/site-packages/mathics/core/load

Mathics 7.0.0
on CPython 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
using SymPy 1.12.1, mpmath 1.3.0, numpy 1.26.4, cython Not installed

Copyright (C) 2011-2024 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.

Quit by evaluating Quit[] or by pressing CONTROL-D.

In[1]:=

For the message No module named 'packaging'; Not able to load mathics.builtin.numbers.numbertheory, I indeed found that packaging was missing. Installing it via pip removed that message (but the other two messages remain). It appears that packaging is missing from the dependency list.

tueda avatar Aug 10 '24 08:08 tueda

I tried a fresh installation of version 7.0.0 and encountered the following messages (the following log was with Python 3.10 but the same with Python 3.12):

This dependency was included recently to determine which version of Sympy is installed in the system. This was needed due to recent changes in the Sympy API. For some reason, the CI didn't detect a problem with this (I thought packaging was in the standard library). Adding the package as a dependency should solve the issue.

mmatera avatar Aug 10 '24 11:08 mmatera