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.Sat, 06 Jul 2019 19:48:57 +0200SAGE 8.1, cannot import python modules from notebookhttps://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/I'm running into trouble trying to setup SAGE 8.1.
What happened is the following.
I'm working in Linux Ubuntu 16.4. I installed SAGE 7.5.1 from command-line. Then I installed SAGE 8.1 from pre-built binaries. I deleted the old sage version and now when I run the command sage, it tries to find SAGE 7.5.1 and fails.
I already ran:
ln -s /SageMath8.1/sage /usr/local/bin/sage
And nothing changed. Even though I can run SAGE 8.1 with:
/SageMath8.1/.sage
But once there I cannot import python modules:
>>> import pandas as pd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-af55e7023913> in <module>()
----> 1 import pandas as pd
ImportError: No module named pandas
I guess there's a problem with paths, but I don't know how to solve it.
Any help?
Wed, 28 Feb 2018 20:34:14 +0100https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/Answer by Dillon Ethier for <p>I'm running into trouble trying to setup SAGE 8.1.
What happened is the following.
I'm working in Linux Ubuntu 16.4. I installed SAGE 7.5.1 from command-line. Then I installed SAGE 8.1 from pre-built binaries. I deleted the old sage version and now when I run the command sage, it tries to find SAGE 7.5.1 and fails.
I already ran:</p>
<pre><code>ln -s /SageMath8.1/sage /usr/local/bin/sage
</code></pre>
<p>And nothing changed. Even though I can run SAGE 8.1 with:</p>
<pre><code>/SageMath8.1/.sage
</code></pre>
<p>But once there I cannot import python modules: </p>
<pre><code>>>> import pandas as pd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-af55e7023913> in <module>()
----> 1 import pandas as pd
ImportError: No module named pandas
</code></pre>
<p>I guess there's a problem with paths, but I don't know how to solve it.
Any help? </p>
https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?answer=41346#post-id-41346Sage uses its own Python environment that's separate from whichever one(s) you may have previously installed. Try installing the package into Sage with the command
sage -pip install pandas
and see if that helps.Fri, 02 Mar 2018 01:00:01 +0100https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?answer=41346#post-id-41346Comment by vdelecroix for <p>Sage uses its own Python environment that's separate from whichever one(s) you may have previously installed. Try installing the package into Sage with the command</p>
<pre><code>sage -pip install pandas
</code></pre>
<p>and see if that helps.</p>
https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=47087#post-id-47087It is not a bad practice, it is just that with your installation setup, SageMath does not use the system python. You can check which python SageMath does use with
sage -python -c 'import sys; print(sys.executable)'Sat, 06 Jul 2019 19:48:57 +0200https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=47087#post-id-47087Comment by daranha for <p>Sage uses its own Python environment that's separate from whichever one(s) you may have previously installed. Try installing the package into Sage with the command</p>
<pre><code>sage -pip install pandas
</code></pre>
<p>and see if that helps.</p>
https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=41410#post-id-41410is it 'bad practice' to try to use the same python environment?Mon, 05 Mar 2018 18:59:47 +0100https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=41410#post-id-41410Answer by slelievre for <p>I'm running into trouble trying to setup SAGE 8.1.
What happened is the following.
I'm working in Linux Ubuntu 16.4. I installed SAGE 7.5.1 from command-line. Then I installed SAGE 8.1 from pre-built binaries. I deleted the old sage version and now when I run the command sage, it tries to find SAGE 7.5.1 and fails.
I already ran:</p>
<pre><code>ln -s /SageMath8.1/sage /usr/local/bin/sage
</code></pre>
<p>And nothing changed. Even though I can run SAGE 8.1 with:</p>
<pre><code>/SageMath8.1/.sage
</code></pre>
<p>But once there I cannot import python modules: </p>
<pre><code>>>> import pandas as pd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-af55e7023913> in <module>()
----> 1 import pandas as pd
ImportError: No module named pandas
</code></pre>
<p>I guess there's a problem with paths, but I don't know how to solve it.
Any help? </p>
https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?answer=41360#post-id-41360Regarding your trouble understanding what happens when you type `sage` in a terminal:
- run `which sage` to try to figure out what gets run when you type `sage`
- run `echo $PATH` to check what other locations are searched before `/usr/local/bin`
- check if you defined an alias in your `.bashrc` or `.bash_profile` or `.bash_aliases`
(see [this blog post about `.bashrc` and others](https://www.stefaanlippens.net/bashrc_and_others/))
- if the `ln -s` command you ran did not succeed, it might be either because there
already is such an alias there, or because of a permissions problem; try with
sudo ln -sf /SageMath8.1/sage /usr/local/binFri, 02 Mar 2018 15:03:26 +0100https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?answer=41360#post-id-41360Comment by daranha for <p>Regarding your trouble understanding what happens when you type <code>sage</code> in a terminal:</p>
<ul>
<li>run <code>which sage</code> to try to figure out what gets run when you type <code>sage</code></li>
<li>run <code>echo $PATH</code> to check what other locations are searched before <code>/usr/local/bin</code></li>
<li>check if you defined an alias in your <code>.bashrc</code> or <code>.bash_profile</code> or <code>.bash_aliases</code>
(see <a href="https://www.stefaanlippens.net/bashrc_and_others/">this blog post about <code>.bashrc</code> and others</a>)</li>
<li><p>if the <code>ln -s</code> command you ran did not succeed, it might be either because there
already is such an alias there, or because of a permissions problem; try with</p>
<pre><code>sudo ln -sf /SageMath8.1/sage /usr/local/bin
</code></pre></li>
</ul>
https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=41411#post-id-41411Thanks for your answer, though I'm still struggling.
- 'which sage' command didn't provide an answer.
- three locations are searched before '/usr/local/bin': '/home/myself/bin' , '/home/myself/.local/bin', and /usr/local/sbin/'
- I don't understand your third point.
- It cannot create a symbolic link because it already exists.Mon, 05 Mar 2018 19:16:45 +0100https://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=41411#post-id-41411