Closed densnow closed 1 month ago
Good idea. Does it also work on Windows? If so, we could make the nb
alias / cmdlet call the m269-23j
if the environment isn't activated, instead of giving an error.
Yes it does work on windows you just need to get the var with env: VIRTUAL_ENV
syntax.
Having said all that, I think we could just activate the env without any checks in nb
regardless of current state. I.e if the env is not active, then it would be activated. If it was already activated then it can't be activated twice and no harm would come AFAIK from running the activation script when already activated. Of course needs to be tested properly as there might be something not thought of 🙂.
Great, that's even simpler :-)
@densnow We should have addressed this earlier. If you have the time this week to do a branch and PR to address this and test on Win10 + Linux, great, I can then test on Mac and merge.
@densnow I added Bob's script, which changes folder between activating and calling nb
(see new README section 3.1). For this to continue working, nb
can activate but must not change the folder.
Often students can and will use
nb
before usingm269-23j
even though the correct order is documented. If they have no alternative jupyter environment installed, then a "command not found" type error is raised. If they do have an alternative Jupyter environment, then it most likely will not have the correct dependencies for error free operation with the M269 book.When a Python venv is activated, a
VIRTUAL_ENV
environment variable is set with the location of the environment e.g~/venvs/m269-23j
. This allows a relatively straightforward way to check if a specific environment is currently activated and could be incorporated into thenb
aliases on each of the scripts. If the environment is activated, carry on as normal. If not, then print specific error message and instruction to activate the environment.