Mathics3 / mathics-core

An open-source Mathematica. This repository contains the Python modules for WL Built-in functions, variables, core primitives, e.g. Symbol, a parser to create Expressions, and an evaluator to execute them.

Home Page:https://mathics.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected MathicsSession warnings

rochant opened this issue · comments

Description

How to Reproduce

The python file (test.py) is:
from mathics.session import MathicsSession
session = MathicsSession(add_builtin=True, catch_interrupt=True)

result = session.evaluate('5!').to_python()
print(result)

$python test.py

(mathics6) (base) PS C:\GreenSofts\IDE\tests\python_projects\mathics6> & c:/GreenSofts/IDE/tests/python_projects/mathics6/Scripts/python.exe c:/GreenSofts/IDE/tests/python_projects/mathics6/test_session.py

Output Given

can only concatenate str (not "_GenericAlias") to str
Not able to load strings. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin
can only concatenate str (not "_GenericAlias") to str
Not able to load symbols. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin
can only concatenate str (not "_GenericAlias") to str
Not able to load io. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin
can only concatenate str (not "_GenericAlias") to str
Not able to load htmlformat. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin
can only concatenate str (not "_GenericAlias") to str
Not able to load xmlformat. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin
Not able to load charcodes. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin\can only concatenate str (not "_GenericAlias") to str
Not able to load operations. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin\can only concatenate str (not "_GenericAlias") to str
Not able to load patterns. Check your installation.
mathics.builtin loads from C:\GreenSofts\IDE\tests\python_projects\mathics6\lib\site-packages\mathics\builtin
120

Expected behavior

120

Your Environment

  • OS: Windows 11

Both mathics and mathicsscript.

Workarounds

Priority

Additional context

I have the same issue

The warnings are shown before or after the evaluation?

What about the output of the following modified script?

test2.py

from mathics.session import MathicsSession
print("Creating the session:\n")
session = MathicsSession(add_builtin=True, catch_interrupt=True)
print(10*"*","\n", "evaluating:")
result_expr = session.evaluate('5!')
print(10*"*","\n", "converting to python:")
result = result_expr.to_python()
print(result)

For me the warnings are shown before the evaluation, at :
session = MathicsSession(add_builtin=True, catch_interrupt=True)

Here's the output of your modified script :

Creating the session:

can only concatenate str (not "_GenericAlias") to str
    Not able to load strings. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load symbols. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load io. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load htmlformat. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load xmlformat. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load files. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load filesystem. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load charcodes. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load operations. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
can only concatenate str (not "_GenericAlias") to str
    Not able to load patterns. Check your installation.
    mathics.builtin loads from c:\users\alexi\anaconda3\lib\site-packages\mathics\builtin\
********** 
 evaluating:
********** 
 converting to python:
120

It seems that in your configuration there are problems loading some of the builtin modules. Which version of the code are you using? The current master or some of the releases?

I installed it yesterday from PyPi so i guess i'm using the current master, how can i verify ?

What is the output of

import mathics
mathics.__version__

?

The output of

import mathics
print(mathics.__version__)

is
6.0.1

The issue is related to the way in which the formatters in mathics.format are loaded. If the formatters are not loaded at the right time, some builtin modules can not be properly loaded, which is the reason for the warnings.

#845 partially fixes this, allowing that MathicsSession to be created without problems; hence, the warnings disappear.

I have the same issue. mathics Version 5.0.2 works fine. But error occurs since mathics 6.0

@rochant try the code in #845 and let us know if this fixes the problem. Thanks.

I confirmed that #845 fixed this problem. Thanks.