Skip to content

πŸ€ Loading VirtualEnv in Spartan

rNLKJA edited this page Mar 29, 2023 · 2 revisions

Before loading virtualenv module, you need to login spartan.

  1. load a python module which contains a virtualenv builtin.
# the example use python3.9.6, therefore as a result, virtual env will have a python version 3.9.6
module load python/3.9.6
python3 --version # this should return Python 3.9.6

# check virtualenv existence
which virtualenv
# output: /usr/local/easybuild-2019/easybuild/software/compiler/gcccore/11.2.0/python/3.9.6/bin/virtualenv
  1. create a virtual env
# create a virtualenv folder in user root directory
mkdir ~/virtualenv

# move to virtualenv
cd ~/virtualenv

# create a virtualenv use current python version
virtualenv python3.9.6 # a python folder named python3.9.6 will present in virtualenv folder
  1. activate virtualenv python3.9.6
source ~/virtualenv/python3.9.6/bin/activate

After activate a virtual environment, the terminal should be like this: image

In your virtualenv, install any wanted/required packages using pip command.

To deactivate a virtualenv, simply use the command: deactivate.

Clone this wiki locally