ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 26 Aug 2021 10:10:24 +0200Installing packages using pip for Sage installed via apthttps://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/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...Sat, 04 Jul 2020 18:39:35 +0200https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/Answer by eric_g for <p>Recently I tried to install packages for Sage using pip. Often the descriptions says to execute something like</p>
<pre><code>sage -pip install package_name
</code></pre>
<p>If I execute that in the terminal I get the error</p>
<pre><code>sage-run received unknown option: -pip
</code></pre>
<p>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 <code>pip install ...</code> and <code>-pip install ...</code>. All lead to a syntax error. What do I do wrong? This happens with all packages I tried.</p>
<p>I use a freshly installed virtual machine with Ubuntu 18.04 and SageMath version 8.1 which I installed using <code>sudo apt install sagemath</code>. Sage itself works perfectly fine and I can start it with <code>sage</code> from the terminal.</p>
<p>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...</p>
https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?answer=52338#post-id-52338Instead 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-linux.html. In that version, you can run `sage -pip install` without any trouble; moreover, you'll get a much more recent version of Sage.Sun, 05 Jul 2020 14:56:30 +0200https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?answer=52338#post-id-52338Answer by slelievre for <p>Recently I tried to install packages for Sage using pip. Often the descriptions says to execute something like</p>
<pre><code>sage -pip install package_name
</code></pre>
<p>If I execute that in the terminal I get the error</p>
<pre><code>sage-run received unknown option: -pip
</code></pre>
<p>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 <code>pip install ...</code> and <code>-pip install ...</code>. All lead to a syntax error. What do I do wrong? This happens with all packages I tried.</p>
<p>I use a freshly installed virtual machine with Ubuntu 18.04 and SageMath version 8.1 which I installed using <code>sudo apt install sagemath</code>. Sage itself works perfectly fine and I can start it with <code>sage</code> from the terminal.</p>
<p>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...</p>
https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?answer=52329#post-id-52329The 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`.Sat, 04 Jul 2020 23:52:12 +0200https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?answer=52329#post-id-52329Comment by slelievre for <p>The Sage you installed using <code>sudo apt install sagemath</code> uses the system Python.</p>
<p>So you can simply use</p>
<pre><code>pip install package_name
</code></pre>
<p>Hopefully in the future we can make it so that</p>
<pre><code>sage --pip install package_name
</code></pre>
<p>also works in the case when Sage is installed via a package manager such as <code>apt</code>,
or at least prints out a helpful message telling the user to use <code>pip</code>
instead of <code>sage --pip</code> or <code>sage -pip</code>.</p>
https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?comment=58693#post-id-58693To 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.Thu, 26 Aug 2021 10:10:24 +0200https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?comment=58693#post-id-58693Comment by philipp7 for <p>The Sage you installed using <code>sudo apt install sagemath</code> uses the system Python.</p>
<p>So you can simply use</p>
<pre><code>pip install package_name
</code></pre>
<p>Hopefully in the future we can make it so that</p>
<pre><code>sage --pip install package_name
</code></pre>
<p>also works in the case when Sage is installed via a package manager such as <code>apt</code>,
or at least prints out a helpful message telling the user to use <code>pip</code>
instead of <code>sage --pip</code> or <code>sage -pip</code>.</p>
https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?comment=52342#post-id-52342I 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!Sun, 05 Jul 2020 18:42:19 +0200https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?comment=52342#post-id-52342Comment by philipp7 for <p>The Sage you installed using <code>sudo apt install sagemath</code> uses the system Python.</p>
<p>So you can simply use</p>
<pre><code>pip install package_name
</code></pre>
<p>Hopefully in the future we can make it so that</p>
<pre><code>sage --pip install package_name
</code></pre>
<p>also works in the case when Sage is installed via a package manager such as <code>apt</code>,
or at least prints out a helpful message telling the user to use <code>pip</code>
instead of <code>sage --pip</code> or <code>sage -pip</code>.</p>
https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?comment=52336#post-id-52336Thank 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"Sun, 05 Jul 2020 10:49:43 +0200https://ask.sagemath.org/question/52321/installing-packages-using-pip-for-sage-installed-via-apt/?comment=52336#post-id-52336