ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 05 Mar 2018 12:16:45 -0600SAGE 8.1, cannot import python modules from notebookhttp://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 13:34:14 -0600http://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/Answer 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>
http://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`
- if the `ln -s` command you ran did not succeed, try with
sudo ln -sf /SageMath8.1/sage /usr/local/bin
Fri, 02 Mar 2018 08:03:26 -0600http://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></li>
<li><p>if the <code>ln -s</code> command you ran did not succeed, try with</p>
<p>sudo ln -sf /SageMath8.1/sage /usr/local/bin</p></li>
</ul>
http://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 12:16:45 -0600http://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=41411#post-id-41411Answer 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>
http://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.Thu, 01 Mar 2018 18:00:01 -0600http://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?answer=41346#post-id-41346Comment 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>
http://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 11:59:47 -0600http://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/?comment=41410#post-id-41410