Ask Your Question
0

Python3.11 Cpython issue, can't open app

asked 2023-02-08 05:02:46 +0200

wayneyam gravatar image

I'm not a native speaker, sorry for poor English

I installed sagemath through sudo apt install sagemath yesterday and tried to import sage.all from python, however I was hit with

Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python3/dist-packages/sage/all.py", line 83, in <module>
        import sage.misc.lazy_import
ModuleNotFoundError: No module named 'sage.misc.lazy_import'

After a bit of work I found that .pyx files can't be imported, and import pyximport; pyximport.install() works to mitigate that error, however I was hit with another error:

Traceback (most recent call last):
  File "/home/wayne/.local/lib/python3.11/site-packages/pyximport/pyximport.py", line 216, in load_module
    mod = imp.load_dynamic(name, so_path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/imp.py", line 343, in load_dynamic
    return _load(spec)
           ^^^^^^^^^^^
ImportError: /home/wayne/.pyxbld/lib.linux-x86_64-cpython-311/sage/misc/randstate.cpython-311-x86_64-linux-   gnu.so: undefined symbol: __gmp_randclear

Which I suppose is still related to Cython, I wasn't able to resolve this.

When running sage in terminal here's the output

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.0, Release Date: 2020-01-01                     │
│ Using Python 3.11.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘

 Traceback (most recent call last):
  File "/usr/share/sagemath/bin/sage-ipython", line 12, in <module>
    from sage.repl.interpreter import SageTerminalApp
  File "/usr/lib/python3/dist-packages/sage/repl/interpreter.py", line 105, in <module>
    from sage.repl.preparse import preparse, containing_block
  File "/usr/lib/python3/dist-packages/sage/repl/preparse.py", line 227, in <module>
    from sage.repl.load import load_wrap
  File "/usr/lib/python3/dist-packages/sage/repl/load.py", line 19, in <module>
    from sage.cpython.string import str_to_bytes, bytes_to_str, FS_ENCODING
ModuleNotFoundError: No module named 'sage.cpython.string'

After this I tried to import sage.cpython.string python

/home/wayne/.pyxbld/temp.linux-x86_64-cpython-311/pyrex/sage/cpython/string.c:744:10: fatal error: string_impl.h: No such file or directory
  744 | #include "string_impl.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.

I think these are all somehow related, I was not able to resolve them, any ideas are appreciated

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2023-02-10 14:43:33 +0200

eric_g gravatar image

It seems you have installed a rather recent version of Python on that computer, given that Ubuntu 20.04 comes only with Python 3.8. The SageMath package for Ubuntu 20.04 is outdated: it is 9.0 while the current stable version is 9.7 (9.8 soon). I would recommend that you install Sage 9.8.rc1 (which does support Python 3.11) from source. This is quite easy on Ubuntu: see https://sagemanifolds.obspm.fr/instal...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-02-08 05:02:46 +0200

Seen: 784 times

Last updated: Feb 10 '23