Ask Your Question
1

Sage in python no module called sage.all

asked 2020-12-23 20:42:06 +0200

standardtrickyness gravatar image

So I think I'm suppose to write the line from sage.all import * in my python script which raises the error

File "c:/Users/user/Downloads/PyFolder/umphy.py", line 2, in <module> from sage.all import * ModuleNotFoundError: No module named 'sage.all'

So I tried installing sage in python.

PS C:\Users\user> pip install sage Requirement already satisfied: sage in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (0.0.0)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-23 22:01:21 +0200

slelievre gravatar image

updated 2020-12-25 12:26:57 +0200

The line from sage.all import * will work only on a Python which has the Sage library installed.

Depending on how you installed Sage, this might be your system Python or a different one.

The "sage" package on the Python package index (PyPI) is not SageMath.

As far as I know it is not related to SageMath at all.

There is also a "sagemath" package on PyPI but it only serves to check whether SageMath is installed, and does not provide SageMath.

So far, Sage is not available on PyPI. Making that happen is a goal, tracked at:

If you have SageMath installed, use your Python script with Sage's Python instead of your system Python, and then importing (from) sage or sage.all will work.

That is, under Windows, instead of running from the Windows command prompt

$ python umphy.py

open the "Sage shell" shortcut that was placed on your desktop by the Sage-Windows installer and in there, run

$ python umphy.py
edit flag offensive delete link more

Comments

Sorry, I don't quite understand how do I use my python script with Sage's python? Can you dumb it down for me?

standardtrickyness gravatar imagestandardtrickyness ( 2020-12-25 02:48:29 +0200 )edit

Edited to address your question.

Say more on how you were using your Python script if that's still not helpful.

slelievre gravatar imageslelievre ( 2020-12-25 12:28:31 +0200 )edit

So if I run in shell python umphy.py
I get
python: can't open file 'umphy.py': [Errno 2] No such file or directory

If I run in sage console I get sage: python umphy.py File "<ipython-input-1-4d6f435033d8>", line 1 python umphy.py

In the shell, I'm in the user's folder do I need to be in a different folder?

standardtrickyness gravatar imagestandardtrickyness ( 2020-12-25 22:10:28 +0200 )edit

Either run python umphy.py after changing to the directory where it lives:

cd "c:/Users/user/Downloads/PyFolder/"
python umphy.py

or, from your home directory, use the complete path; try one of these maybe:

python "c:/Users/user/Downloads/PyFolder/umphy.py"
sage --python "c:/Users/user/Downloads/PyFolder/umphy.py"

Or can you say how you were running your script before I wrote anything, and I can try to suggest something closer to that?

Were you using the Windows command prompt? Some graphical user interface provided by the version of Python you downloaded? Anaconda? Eclipse? IDLE? PyCharm? Spyder? Visual Studio Code? Another "IDE"?

slelievre gravatar imageslelievre ( 2020-12-26 01:52:27 +0200 )edit

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-12-23 20:42:06 +0200

Seen: 6,535 times

Last updated: Dec 25 '20