Ask Your Question

Installing packages using pip for Sage installed via apt

asked 2020-07-04 11:39:35 -0500

philipp7 gravatar image

updated 2020-07-04 16:54:58 -0500

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 16:52:12 -0500

slelievre gravatar image

updated 2020-07-04 16:58:20 -0500

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 03:49:43 -0500 )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 11:42:19 -0500 )edit

answered 2020-07-05 07:56:30 -0500

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 11:39:35 -0500

Seen: 139 times

Last updated: Jul 04