Ask Your Question

Installing packages using pip for Sage installed via apt

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

philipp7 gravatar image

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

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

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

slelievre gravatar image

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

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


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 +0200 )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 +0200 )edit

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

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 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

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


Asked: 2020-07-04 18:39:35 +0200

Seen: 846 times

Last updated: Jul 04 '20