6

I would like to use cubegroup of sagemath. I did as follows.

python -m pip install sagemath

and then

import sagemath.cubegroup;

in python script. But I got the following error.

ImportError: No module named cubegroup

I tried both python2 and python3 but neither worked. I also tried sage instead of sagemath, but didn't work either.

How can I use sagemath and cubegroup on python?

nemy
  • 519
  • 5
  • 16
  • First, is Sage installed on your system? If not, the module won't work. If it is, try `from sagemath import cubegroup`. – MattDMo May 07 '21 at 19:48
  • I installed the following binary, but still it doesn't work. https://github.com/sagemath/sage-windows/releases/download/0.6.2-9.2/SageMath-9.2-Installer-v0.6.2.exe – nemy May 08 '21 at 06:42
  • Which OS are you using? Does sudo apt install sagemath work? – smitty_werbenjagermanjensen Oct 06 '21 at 15:53
  • @smitty_werbenjagermanjensen Windows 10, with binaries installed from http://www-ftp.lip6.fr/pub/math/sagemath/index.html – Desura Oct 06 '21 at 16:02
  • @desura i used this when installing sagemath on linux im thinking it may help you for installing on windows if not i can take a closer look later https://doc.sagemath.org/pdf/en/installation/installation.pdf – smitty_werbenjagermanjensen Oct 06 '21 at 17:06
  • @smitty_werbenjagermanjensen For Windows, this document basically tells you to install some pre-built binaries, which I did. The problem is not the installation of SageMath but how to make it work with some editor like PyCharm. – Desura Oct 07 '21 at 06:05
  • @Desura sounds like your looking for this https://ask.sagemath.org/question/39742/make-pycharm-recognise-the-sage-python-interpreter/ – smitty_werbenjagermanjensen Oct 07 '21 at 12:45

1 Answers1

1

The sagemath package on PyPI, which you get by running

python -m pip install sagemath

does not install Sage, it only allows to check whether Sage is installed.

It seems you are working on Windows and you installed Sage using the Sage-Windows installer.

The command

import sage.cubegroup

will work only if you use Sage's Python.

If you are using Python via some integrated development environment such as PyCharm, you need to set it up to use Sage's Python. See instructions in Iguananaut's answer to:

Samuel Lelièvre
  • 3,212
  • 1
  • 14
  • 27
  • I trid c:/SageMath9.2/runtime/bin/python3.7m.exe, but I got the following error. `ModuleNotFoundError: No module named 'sage'`. I tested both `import sage.cubegroup;` and `import sagemath.cubegroup;`. I also tried to install the modules as `python3.7m -m pip install sage`, but I got the following error. `No module named pip`. **Why Sage's python cannot find sage??** – nemy May 12 '21 at 09:46
  • Btw, I did it on C:\SageMath9.2\runtime\bin\bash.exe. – nemy May 12 '21 at 09:53
  • I agree with @nemy. The instructions from Iguananaut's answer does not work for SageMath 9.2, installed with Windows binaries from http://www-ftp.lip6.fr/pub/math/sagemath/index.html – Desura Oct 06 '21 at 15:51