Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Importing Python packages into Sage or Vice Versa

Hi all,

this is my first post. I'm a long time user of Python, and I'm fairly new to Sage. I'm using Ubuntu, if this helps. Currently, python doesn't recognize any of Sage's packages, and Sage can't import even standard Python packages like pandas.

I've looked at various instructions online about how to import sage packages into python and vice versa, but they all seem incredibly intricate, and none of them seem to work for me.

Here are a few attempts that I made:

  1. Running "sudo sagemath --python -m easy_install pandas" in terminal. (Still can't import pandas while running sage; even after running: "sys.path.append('/usr/lib/sagemath/local/lib/python2.7/site-packages/pandas-0.19.1-py2.7-linux-x86_64.egg')" from within sage.)
  2. Following the instructions in the "import sage packages in python" question. (I don't have enough karma to post links.)
  3. Doing various bizzarre attempts at changing sage_root or adding to it my python path.
  4. Attempting to import pip while running sage, and install pandas this way. (Can't import pip.)

I tried a few more things (like downloading packages and "build"ing them, and then doing a few more very technical and annoying things), and all of my attempts fail. Is there really no simple way to do this? What is the most fool-proof way to do this that exists? It would be enormously helpful for me to be able to use python packages while working in sage, or vice versa.