Setting environment variables
An environment variable is a variable set outside of a program: it is then available to shell commands, Python or R scripts, etc. The benefit of using such variables is that they allow the same code to work in different environments: if BLab share is mounted to Z:\ on one machine, Y:\ on another, and /Volumes/Fas-Phyc-PEB-Lab
on yet another one, a program can use the value of the PN_OPUS_PATH
environment variable set on each machine to Z:\, Y:\, and /Volumes/Fas-Phyc-PEB-Lab respectively.
On MacOS
The instructions will depend on which shell you are using (run ps -p $$
and look at the CMD column in the output if unsure). For bash, edit ~/.bash_profile
n, for zsh, edit ~/.zprofile
. In both cases, add the following line to set BLAB_SHARE_PATH
to /Volumes/Fas-Phyc-PEB-Lab
On Windows
Click on the Start button.
Start typing "environment".
Select "Edit environment variables for your account" (or something similar, just not something with "the system").
Click "New"/"Add".
To set
PN_OPUS_PATH
toZ:\
, usePN_OPUS_PATH
as the name andZ:\
as the value.
For a terminal session
Run the following command to set BLAB_SHARE_PATH
to /Volumes/Fas-Phyc-PEB-Lab
For a single command
To run a python script called foo.py
that resides in the current directory, temporarily setting the environment variable PN_OPUS_PATH
to Volumns/pn-schmopus
, run
Last updated