Chun Sing Tsui

Coding, Technology, and other Interests

Virtual Environment Cheatsheet

For those who work with virual environments when developing, here’s a handy cheatsheet in case you need to switch between various virt-envs.

RVM for Ruby

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# List existing environments
rvm list

# Create new environment
rvm install 2.6.3

# Set default
rvm --default use 2.6.3

# Switch back to system's ruby
rvm use system

# Use a specific version
rvm use 2.1.1

anaconda for Python

1
2
3
4
5
6
7
8
9
10
11
# List existing environments
conda env list

# Create new environment
conda create --name py38 python=3.8

# Activate environment
conda activate py38

# Deactivate environment
conda deactivate

virtualenv for Python

1
2
3
4
5
6
7
8
9
10
11
# Create new environment (using the current Python version)
virtualenv my-env

# Create new environment (using a different Python version)
virtualenv -p /usr/bin/python2.7 my-env

# Activate new environment
source my-env/bin/activate

# Deactivate active environment
deactivate