Ask Your Question
1

How to upgrade sagemath from 9.6 to 9.8 using mamba?

asked 2023-05-11 11:44:03 +0100

Sébastien gravatar image

updated 2023-05-11 16:03:41 +0100

In the documentation, it is explained how to install sage using mamba with the line:

mamba create -n sage sage python=3.9

This line was run few months ago to installed sagemath 9.6 on the computer (MacBookAir) of my colleague Pascal.

What line should be run now to upgrade the installation from 9.6 to the most recent version 9.8?

edit retag flag offensive close merge delete

Comments

The command

mamba create -n sage sage=9.8 python=3.9

does not seem to work:

Traceback (most recent call last):
  File "/Users/pascalweil/sagemath-forge/bin/mamba", line 7, in <module>
    from mamba.mamba import main
  File "/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/mamba/mamba.py", line 49, in <module>
    import libmambapy as api
  File "/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/__init__.py", line 7, in <module>
    raise e
  File "/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/__init__.py", line 4, in <module>
    from libmambapy.bindings import *  # noqa: F401,F403
ImportError: dlopen(/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/bindings.cp
Sébastien gravatar imageSébastien ( 2023-05-11 16:02:34 +0100 )edit

Try with python=3.10?

slelievre gravatar imageslelievre ( 2023-05-16 07:00:58 +0100 )edit

The exact same result, alas (including references to .../lib/python3.9/...)

Pascal Weil gravatar imagePascal Weil ( 2023-05-16 10:33:51 +0100 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2023-05-11 16:45:21 +0100

slelievre gravatar image

updated 2023-05-20 18:23:31 +0100

Three options:

  • activate existing "sage" conda environment; upgrade relevant packages
  • create new environment with other name; if it works well, remove old one
  • completely remove existing conda installation; start afresh

Details below for each of these options.

Upgade existing environment

$ conda activate sage  # or: mamba activate sage
$ mamba upgrade sage  # or: mamba update sage

Create new environment

$ mamba create -n sage98 sage=9.8

To list existing conda environments:

$ conda env list

To rename a conda environment:

$ conda rename -n sage98 sage

which in fact creates a new environment and removes the old one, see Stack Overflow answer 42231765 .

Reinstall conda

This assumes you were only using conda for Sage and you don't mind reinstalling it completely.

(Check with conda env list if you have any other conda environments.)

The sagemath-forge distribution you installed might no longer be maintained.

Remove it:

$ rm -rf ~/sagemath-forge
$ rm -rf ~/.conda

Remove any conda traces from ~/.zshrc (in your favourite text editor).

Reinstall, taking inspiration from the "Install from conda-forge" instructions at

First, install mambaforge:

$ curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh
$ sh Mambaforge-$(uname)-$(uname -m).sh

This starts an installation scripts which guides you in installing Mambaforge. Follow the script's instructions, which sometimes involve typing "yes", or hitting Enter, etc. (if in doubt, use the suggested defaults).

Once this is done, the last few lines tell you to open a new terminal.

In this new terminal window, if the conda base environment gets auto-activated, and that annoys you, run

$ conda config --set auto_activate_base false

and open yet another terminal window to see that taken into account.

In this new terminal window, type one of the following, depending whether you want a specific Python version or are happy with any.

$ mamba create -n sage sage=9.8
$ mamba create -n sage sage=9.8 python=3.11
$ mamba create -n sage sage=9.8 python=3.10

Mamba will solve the constraints for installing the requested software, and propose a choice of package versions. Accept it and let it install.

Once that is done, I suggest installing a very recent version of JupyterLab into the "sage" conda environment.

The latest versions, and what conda-forge label to use to get them, are listed at

As of May 20, 2023, one might want to install JupyterLab 4.0.0rc1 as follows:

$ conda activate sage
$ mamba install -c conda-forge/label/jupyterlab_rc jupyterlab=4.0.0rc1

Install any other things you might want (with the sage conda environment active).

For instance the pari_jupyter package:

$ mamba install -c conda-forge pari_jupyter

which will allow you to use Jupyter sheets using a PARI/GP kernel.

Done installing.

To use your new installation, in any new terminal window, activate the sage conda environment:

$ conda activate sage

then run one of:

$ sage  # to use the Sage REPL
$ jupyter lab  # to use Sage in Jupyter

Happy computing!

edit flag offensive delete link more

Comments

Thanks Samuel!

Pascal Weil gravatar imagePascal Weil ( 2023-05-25 16:24:46 +0100 )edit

Did reinstalling work?

slelievre gravatar imageslelievre ( 2023-05-25 16:35:45 +0100 )edit
0

answered 2023-05-12 11:58:03 +0100

Pascal Weil gravatar image

updated 2023-05-14 18:49:26 +0100

slelievre gravatar image

Alas, something is the matter.

$ conda activate sage

works fine, but not

$ mamba upgrade sage

, see below. Some libarchive is missing.

(sage) pascalweil@MacBook-Air-2022-PW ~ % conda activate sage

(sage) pascalweil@MacBook-Air-2022-PW ~ % mamba upgrade sage

Traceback (most recent call last):
  File "/Users/pascalweil/sagemath-forge/bin/mamba", line 7, in <module>
    from mamba.mamba import main
  File "/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/mamba/mamba.py", line 49, in <module>
    import libmambapy as api
  File "/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/__init__.py", line 7, in <module>
    raise e
  File "/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/__init__.py", line 4, in <module>
    from libmambapy.bindings import *  # noqa: F401,F403
ImportError: dlopen(/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/bindings.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libarchive.13.dylib
  Referenced from: <91CFAC3D-BB83-3877-9EEE-54AC5B013662> /Users/pascalweil/sagemath-forge/lib/libmamba.2.0.0.dylib
  Reason: tried: '/Users/pascalweil/sagemath-forge/lib/libarchive.13.dylib' (no such file), '/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/../../../libarchive.13.dylib' (no such file), '/Users/pascalweil/sagemath-forge/lib/python3.9/site-packages/libmambapy/../../../libarchive.13.dylib' (no such file), '/Users/pascalweil/sagemath-forge/bin/../lib/libarchive.13.dylib' (no such file), '/Users/pascalweil/sagemath-forge/bin/../lib/libarchive.13.dylib' (no such file), '/usr/local/lib/libarchive.13.dylib' (no such file), '/usr/lib/libarchive.13.dylib' (no such file, not in dyld cache)
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

2 followers

Stats

Asked: 2023-05-11 11:44:03 +0100

Seen: 823 times

Last updated: May 20 '23