Ask Your Question
1

Ubuntu 18.04 apt install - ModuleNotFoundError: No module named 'sage'

asked 2020-05-26 09:27:55 +0100

banksiaboy gravatar image

updated 2022-01-21 11:10:33 +0100

FrédéricC gravatar image

I'm on Ubuntu 18.04.4 LTS.

 % sudo aptitude install sage  
[...]
% which sage                    
/usr/bin/sage
 % sage --version 
SageMath version 8.1, Release Date: 2017-12-07

then

% sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.1, Release Date: 2017-12-07                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
  File "/usr/share/sagemath/bin/sage-ipython", line 7, in <module>
    from sage.repl.interpreter import SageTerminalApp
ModuleNotFoundError: No module named 'sage'

Conda provides my Python. I did not install sagemath using Conda - couldn't get it to run. I was assuming the platform package would work.

Is there a simple solution?

Cheers, --PG

edit retag flag offensive close merge delete

Comments

Deactivate conda and try again.

vdelecroix gravatar imagevdelecroix ( 2020-05-26 10:21:44 +0100 )edit

That's like 'cycle-the-power'. Which we all use sometimes :-)

banksiaboy gravatar imagebanksiaboy ( 2020-06-14 23:38:36 +0100 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2020-06-14 23:36:51 +0100

banksiaboy gravatar image

I have a reliable install method for SageMath on Ubuntu 18.04. referring to: https://doc.sagemath.org/html/en/inst...

in the conda base environment:
% conda install mamba -c conda-forge

using an ./environment.yml in a chosen directory:

name: SageMath
channels:
  - conda-forge
  - anaconda
  - defaults
dependencies:
  - conda-forge::sage
  - conda-forge::mamba
  - anaconda::python>=3.7
  - nodejs
  - pip

run:
mamba env create --file ./environment.yml

edit flag offensive delete link more

Comments

Oh and the :: syntax in the environment.yml forces the module to be loaded from ether particular repository. It is a supported, but undocumented feature. I have asked for it to be documented.

banksiaboy gravatar imagebanksiaboy ( 2020-06-19 01:28:34 +0100 )edit
0

answered 2020-05-26 13:49:19 +0100

Masacroso gravatar image

updated 2020-05-27 09:40:54 +0100

Alternatively you can download the last version of sagemath from it official web, then (after you have cleaned your not working installation of sage, say you have uninstalled it) you can do the following:

  1. Extract the file that contains sage to some folder, this would be the installation folder of sagemath.

  2. Install (if it is not already installed) jupyter.

  3. Now you need to add the sage kernel to jupyter running this command in the terminal (assuming that jupyter is available in your PATH):

     jupyter kernelspec install --user /folder-of-sage/local/share/jupyter/kernels/sagemath
    

    where /folder-of-sage is the direction of the folder where you have extracted sage.

  4. Now run in the terminal jupyter kernelspec list, this gives a list of the installed kernels of jupyter and the folder where each kernel was installed. Then open the folder where the kernel of sage was installed and the kernel.json file that you will find there, open it with some text editor and add the following just before the last }

    ,"env":{"SAGE_ROOT":"/folder-of-sage"}
    

    Finally save the file and close it.

And this is all. Now you can open jupyter (or jupyter lab) and find that the kernel of sage is installed and works correctly (to run jupyter you can run jupyter lab in a terminal.)

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: 2020-05-26 09:27:55 +0100

Seen: 2,432 times

Last updated: Jun 14 '20