Automate launching Sage notebook with mamba in WSL

asked 2024-02-23 21:00:58 +0200

Road gravatar image

updated 2024-02-23 21:04:24 +0200

In WSL (Ubuntu), I have created a shell script ~/

mamba activate sageforge
cd /mnt/g/<somepath>
sage -n jupyter --NotebookApp.use_redirect_file=False

However, simply running the script via the command ~/ results in errors:

Run 'mamba init' to be able to run mamba activate/deactivate and st art a new shell session. Or use conda to activate/deactivate.

I found out that running source ~/ would work. However, this assumes that I manually launch ubuntu WSL and then run source ~/ I would like to automate this entire process.

Creating and running a Window batch script with the command ubuntu run "source ~/" results in error:

mamba: command not found

I believe this is because mamba needs some preprocessing that is usually done by launching ubuntu manually.

edit retag flag offensive close merge delete


Try using a login shell, i.e. adding #!/bin/bash --login at the top of your shell script.

rburing gravatar imagerburing ( 2024-02-24 00:21:33 +0200 )edit

This doesn't work. ubuntu run "source ~/" and "ubuntu run ~/" still result in mamba: command not found and sage: command not found.

Road gravatar imageRoad ( 2024-02-26 21:44:40 +0200 )edit