This article will help you create a python virtual environment. In this example, we'll create one on a Bren computing server.
- Log into a Bren computing server.
- Open up Terminal session in either JupyterLab or Jupyter Notebooks.
- Run the following commands:
To see if python is pointing to correct python3 install.
which python3
Check that you are in the root of your home folder (or where you want to store your virtual environment). File path of your home folder is /Users/(BrenUsername)
pwd
Create environment
python3 -m venv environment_name
View top level tree of virtual environment
tree -d -L 1 environment_name
Activate virtual environment
. /Users/(BrenUsername)/environment_name/bin/activate
Register kernel with Jupyter
ipython kernel install --user --name=environment_name
Verify that kernel is registered with Jupyter
jupyter kernelspec list
Once you're done, you can deactivate the environment.
. /Users/(brenusername)/environment_name/bin/deactivate
Then remove kernel from Jupyter
jupyter kernelspec uninstall environment_name
____________
If you have any questions or run into any issues, please feel free to send us an email at compute@bren.ucsb.edu.