carpentries-lab / python-aos-lesson

Python for Atmosphere and Ocean Scientists
https://carpentries-lab.github.io/python-aos-lesson/
Other
87 stars 48 forks source link

Troubles with conda environments on windows #3

Closed DamienIrving closed 6 years ago

DamienIrving commented 6 years ago

In preparation for this PyAOS workshop, participants are required to follow the Software Carpentry software installation instructions to install Anaconda. Windows users are also required to install a terminal emulator called Git BASH.

For the generic Software Carpentry Python lessons, this all works fine. Once Anaconda and Git BASH are installed, windows users can type "python" at the Git BASH command prompt to start a python command line session.

An unexpected problem I had upon teaching the PyAOS lesson on software installation using conda is that windows users can't type "conda" at the Git BASH command prompt (even if they follow our instructions correctly and check the box to make the Anaconda python the default python).

While this was annoying, it would be possible to get around this issue by re-writing the lesson so that packages are installed using the Anaconda Navigator GUI rather than at the command line.

The problem that I don't have an obvious solution for is that subsequent lessons require the participant to activate their conda environment (using source activate at the command line) and then execute a Python script.

$ source activate pyaos-lesson
(pyaos-lesson) $ python plot_precipitation_climatology.py -h

My recollections from the workshop is that like the command conda, source activate is also not available at the Git BASH command prompt.

I could remove discussion of conda environments from the lessons altogether, but the ability to export and share conda environments is a real game changer for reproducible research, so I'm reluctant to do that.

Does anyone have any suggested solutions to this problem? (I don't have a windows machine to play around with the configuration of Git BASH.)

ocefpaf commented 6 years ago

The problem that I don't have an obvious solution for is that subsequent lessons require the participant to activate their conda environment (using source activate at the command line) and then execute a Python script.

Maybe this part of the issue can be fixed by using the new syntax to activate/deactivate environment available in the latest conda:

conda activate pyaos-lesson

and to deactivate

conda deactivate pyaos-lesson

I don't have a Windows machine to test this but maybe @msarahan can give an expert opinion on the issue.

msarahan commented 6 years ago

Please see the recent discussion at https://github.com/swcarpentry/python-novice-inflammation/issues/485 for more info

ocefpaf commented 6 years ago

Thanks @msarahan!

DamienIrving commented 6 years ago

Thanks, @msarahan.

If I can't find a willing guinea pig with a windows machine, I might try renting one from Amazon so I can add the following to ~/.bashrc:

. $HOME/AppData/Local/Continuum/anaconda3/Scripts/activate

I can then add this step to the setup instructions of my workshop until such time that the generic Software Carpentry installation instructions are updated.

msarahan commented 6 years ago

You can also use vagrant temporary boxes. I had a partial setup a long time ago: https://github.com/ContinuumIO/vagrant-images/pull/1

Since it's a temporary VM, you don't need to worry about a windows license. It's free. Just destroy it when the license expires, and re-create it.

No idea if the stuff I used in there still works, but maybe it'll help you.

msarahan commented 6 years ago

PS: there's also these VMs: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

DamienIrving commented 6 years ago

In the conversation at https://github.com/swcarpentry/python-novice-inflammation/issues/485, there is now an alternative (and possibly more universal) solution for making the python and conda commands available at the git bash command line on Windows: https://github.com/unt-carpentries/2018-03-14-unt-swc/blob/gh-pages/welcome-checklist.md

ocefpaf commented 6 years ago

@DamienIrving I used this environment.yaml in a workshop last week. It worked without any modification on Linux, Windows and Mac. Thanks to the new activation commands even the install/use instructions were very compact.

The env has git and virtually all the necessary shell commands used in the workshop, so no need for git-shell or any other software. The only caveat was that I had to adapt the bash for loop exercise on Windows a little bit.

PS0: I'm planning on writing a blog post about miniconda+conda-env for SWC soon. PS1: here are the install instruction, not in English though.

DamienIrving commented 6 years ago

From the discussion at https://github.com/swcarpentry/python-novice-inflammation/issues/485 I've developed a software check for participants, so I'll close this issue for now and revisit once the default Software Carpentry installation instructions have been updated.