Ask Your Question
1

How do I start using SageMath in Spyder on macOS?

asked 2020-09-01 00:14:32 +0100

user90664 gravatar image

updated 2021-03-25 13:12:11 +0100

FrédéricC gravatar image

I installed SageMath 9.1 by downloading and running the OSX .dmg, but how do I actually start using it in my Python IDE (Spyder)? I have Python code that uses SageMath functions, which works in CoCalc, but I can't get it to work in Spyder by simply using import sage or import SageMath.

edit retag flag offensive close merge delete

Comments

Can you import sage ? If yes, try from sage.all import *. Else you may need to tell your IDE to use sage own python.

FrédéricC gravatar imageFrédéricC ( 2020-09-01 16:15:46 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-09-01 17:04:23 +0100

slelievre gravatar image

SageMath and Spyder on macOS

Via Conda

One way to go is to install both Sage and Spyder via Conda.

Start from scratch

The "Conda" section of the installation guide explains how to start from scratch by installing Miniconda.

Follow the instructions there, but when creating the environment, make sure to add Spyder (and any extra things if needed):

$ conda config --add channels conda-forge
$ conda create -n sage sage python=3.7 spyder=4

Already have Anaconda

In case Anaconda is already there, all that is left to do is to - either create a "sage" Conda environment with the "sage" Conda package from the conda-forge channel - or install the "sage" Conda package (from the conda-forge channel) into an existing Conda environment In either case, use the Anaconda prompt and type in appropriate commands.

Then in Anaconda navigator, select the "sage" Conda environment (or the environment in which the "sage" Conda package was installed) and launch Spyder.

Related: Stack Overflow question 43592879: How to change Python version in Anaconda Spyder.

Via a downloaded dmg

Instead of using Conda, one might want to use a Sage version downloaded from the SageMath download page.

I don't know how that would work. One would need to either let an existing Spyder know to use Sage's Python, or to install Spyder for Sage's Python.

Hopefully someone can expand on that approach if there is an interest (please leave a comment to indicate interest in this).

Further reading

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-09-01 00:14:32 +0100

Seen: 1,514 times

Last updated: Sep 01 '20