Ask Your Question

Dillon Ethier's profile - activity

2021-03-22 22:12:32 +0200 received badge  Famous Question (source)
2019-07-12 20:36:42 +0200 received badge  Notable Question (source)
2019-07-06 19:50:35 +0200 received badge  Nice Question (source)
2019-07-02 14:35:21 +0200 received badge  Great Answer (source)
2019-01-16 16:31:39 +0200 received badge  Popular Question (source)
2018-03-05 18:59:56 +0200 received badge  Good Answer (source)
2018-03-02 11:39:03 +0200 received badge  Nice Answer (source)
2018-03-02 05:16:27 +0200 received badge  Teacher (source)
2018-03-02 01:34:03 +0200 received badge  Supporter (source)
2018-03-02 01:00:01 +0200 answered a question SAGE 8.1, cannot import python modules from notebook

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.

2018-02-26 08:28:06 +0200 received badge  Student (source)
2018-02-26 02:08:12 +0200 received badge  Editor (source)
2018-02-25 18:26:10 +0200 asked a question How to call Sage from PowerShell in Windows?

I just installed Sage on Windows 10 directly (without using VM), and I'm wondering how I can run sage on a .sage file without typing commands into the sage shell, or just run it in PowerShell. I would like to automate sagetex as much as possible, and I find it's time-consuming to have to go over to the sage shell and type in commands that way. Is there any way to do this from PowerShell, or possibly to automate sending these commands to the sage shell?

Edit: I figured out the following clunky solution and tried to submit it as an answer, but whenever I click submit, nothing happens. I'd rather have it be available to anyone else who might be wondering the same thing.

I managed to get it to work good enough for my purposes- I used the following in a .bat file to run sage on a .sagetex.sage file:

cmd /c C:\Progra~1\SageMath-8.1\runtime\bin\mintty.exe -t SageTeX /bin/bash --login -c "cd %cygpath% && /opt/sagemath-8.1/sage %2.sagetex.sage | tee %2.sagetex.log" | more

where cygpath is a variable representing the absolute path to the current directory as cygwin would represent it (i.e. with forward slashes and beginning with /cygdrive/drive/ instead of drive:\ - this required some light pre-processing), and %2 is the basename of the .tex file (without the extension). I tried calling sage on the absolute path of the file, but it never worked, which is why I cd into the directory first before running sage. The pipe to tee just makes it so I get a log of sage's processing, since the sage shell window auto-closes whenever it's done.

One major thing is that I absolutely could not get this to work without renaming my root Sage directory to SageMath-8.1 since by default it installs in "SageMath 8.1" with a space which was causing a lot of problems. Essentially cmd can't handle having more than one quoted string, and I absolutely needed to have the last part quoted. This doesn't seem to have broken anything with Sage, though it did require me to reroute all my existing shortcuts.

The pipe to "more" at the end just ensures that the script won't continue until sage is done processing the .sagetex.sage file. It won't help to run pdflatex again until that time.

Now I can automatically run sagetex directly from Notepad++ with the help of nppexec. I'd upload the .bat file, but apparently I'm not allowed to attach anything. I mostly just adapted the script found at https://tex.stackexchange.com/questio... with a few extra lines after the intial run of pdflatex.

To call from Powershell, you only have to modify this by replacing "cmd /c" with just an ampersand "&"

If anyone knows of a less clunky way to do this, please feel free to share it.