First time here? Check out the FAQ!

Ask Your Question
1

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

asked 4 years ago

banksiaboy gravatar image

updated 3 years ago

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

Preview: (hide)

Comments

Deactivate conda and try again.

vdelecroix gravatar imagevdelecroix ( 4 years ago )

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

banksiaboy gravatar imagebanksiaboy ( 4 years ago )

2 Answers

Sort by » oldest newest most voted
1

answered 4 years ago

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

Preview: (hide)
link

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 ( 4 years ago )
0

answered 4 years ago

Masacroso gravatar image

updated 4 years ago

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.)

Preview: (hide)
link

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: 4 years ago

Seen: 2,563 times

Last updated: Jun 14 '20