Ask Your Question

SAGE 8.1, cannot import python modules from notebook

asked 2018-02-28 13:34:14 -0500

daranha gravatar image

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:


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?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2018-03-01 18:00:01 -0500

Dillon Ethier gravatar image

updated 2018-03-02 07:03:17 -0500

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

sage -pip install pandas

and see if that helps.

edit flag offensive delete link more


is it 'bad practice' to try to use the same python environment?

daranha gravatar imagedaranha ( 2018-03-05 11:59:47 -0500 )edit

answered 2018-03-02 08:03:26 -0500

slelievre gravatar image

Regarding 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

edit flag offensive delete link more


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

daranha gravatar imagedaranha ( 2018-03-05 12:16:45 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-02-28 13:34:14 -0500

Seen: 38 times

Last updated: Mar 02