Ask Your Question
2

Installing packages using pip for Sage installed via apt

asked 2020-07-04 18:39:35 +0100

philipp7 gravatar image

updated 2020-07-04 23:54:58 +0100

slelievre gravatar image

Recently I tried to install packages for Sage using pip. Often the descriptions says to execute something like

sage -pip install package_name

If I execute that in the terminal I get the error

sage-run received unknown option: -pip

If I start sage in the terminal and execute it there I get invalid syntax errors. I tried the exact string from above, I tried pip install ... and -pip install .... All lead to a syntax error. What do I do wrong? This happens with all packages I tried.

I use a freshly installed virtual machine with Ubuntu 18.04 and SageMath version 8.1 which I installed using sudo apt install sagemath. Sage itself works perfectly fine and I can start it with sage from the terminal.

I have no real experience with linux, the terminal or with any of that stuff, so I am sure that I miss some really obvious things...

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2020-07-05 14:56:30 +0100

eric_g gravatar image

Instead of using the Ubuntu package installed via sudo apt install, use the SageMath 9.1 binary for Ubuntu 18.04 downloaded from https://www.sagemath.org/download-lin.... In that version, you can run sage -pip install without any trouble; moreover, you'll get a much more recent version of Sage.

edit flag offensive delete link more
3

answered 2020-07-04 23:52:12 +0100

slelievre gravatar image

updated 2020-07-04 23:58:20 +0100

The Sage you installed using sudo apt install sagemath uses the system Python.

So you can simply use

pip install package_name

Hopefully in the future we can make it so that

sage --pip install package_name

also works in the case when Sage is installed via a package manager such as apt, or at least prints out a helpful message telling the user to use pip instead of sage --pip or sage -pip.

edit flag offensive delete link more

Comments

Thank you very much! If I only use "pip install package_name" I get a message with "ModuleNotFoundError: No module named 'sage'" and "ERROR: Command errored out with exit status 1: python setup-py egg_info"

philipp7 gravatar imagephilipp7 ( 2020-07-05 10:49:43 +0100 )edit

I installed sage the way eric_g suggested. Now all those sage -pip install ... work perfectly. I managed to install all the stuff I wanted. Thank you very much for both of your help!

philipp7 gravatar imagephilipp7 ( 2020-07-05 18:42:19 +0100 )edit

To install pip packages for the system Python, you might have to replace pip by pip3 or python -m pip or python3 -m pip.

The solution proposed by @eric_g is better as it gives you a more recent Sage, and I think it should be the accepted answer, please feel free to accept it instead of mine.

slelievre gravatar imageslelievre ( 2021-08-26 10:10:24 +0100 )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-07-04 18:39:35 +0100

Seen: 10,515 times

Last updated: Jul 04 '20