Skip to content

Instantly share code, notes, and snippets.

@richardsalex
Last active March 4, 2016 14:12
Show Gist options
  • Save richardsalex/a03292818a3f372fb320 to your computer and use it in GitHub Desktop.
Save richardsalex/a03292818a3f372fb320 to your computer and use it in GitHub Desktop.
NICAR16 Windows lab computers and Python

NICAR16 Windows lab computers and Python

For those of you who typically do all your Python dev work on a Mac or Linux and are now faced with teaching eager NICAR16 attendees on a Windows computer, fear not. We've taken steps this year to provide Python virtual environments for each scheduled class that work fine with both the standard Windows command prompt or Windows PowerShell.

Where the environments are

The path to the Python virtual environments on the lab computers:

C:\venvs\

Good old command prompt (aka cmd.exe)

Lab computers have virtualenv and virtualenvwrapper-win installed to let you easily activate and deactivate virtual environments. Among the commands that work as expected under the command prompt:

  • workon and workon <ENV>
  • deactivate
  • mkvirtualenv <ENV>
  • etc.

You can find more information about virtualenvwrapper-win and a full list of commands here.

If you'd prefer to use standard virtualenv commands, instead, environments can be activated as follows:

C:\venvs\<ENV NAME>\Scripts\activate

Where <ENV NAME> is the environment name. When you're finished, deactivate works as expected to close the environment.

Windows PowerShell

It's our good fortune that more recent versions of virtualenv come with PowerShell support built in. An activate script is automatically created inside each new environment. To access it:

C:\venvs\<ENV NAME>\Scripts\activate.ps1

Just like when using the Windows command prompt, deactivate to exit the environment.

A note on Jupyter notebooks

Some of you are teaching from Jupyter notebooks, which is great! You may have the class access a specific folder or directory to use a premade .ipynb file or other data. Many of you may aleady know this, but it case you don't — make sure you start the notebook server "upstream" from that folder. The Windows command prompt will open in the main User folder by default (C:\Users\<NMR-assigned username>\); most data will be located in C:\data\ and inaccessible unless you navigate there by typing cd C:\data first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment