Python Virtual environment

This page describe how to set virtual environment in Windows/Ubuntu.


Step by step



1. Install virtualenv

python3.7 -m pip install virtualenv

2. Make virtual env.

python3.7 -m virtualenv `venv-folder-name`

3. Activate Virtualenv

change directory into venv-folder-name(in example, “githubio”) and type activate.

# change directory
cd githubio
# Ubuntu
$ source bin/activate
# Windows
call scripts\activate

If activated successfully, (venv-folder-name) is shown at front of command. (in example, (githubio)). venv

It’s better to double check python version typing like

python -V

python-version


Disable virutal environment


To deactivate, just type deactivate


Tips


Also, you could specify python version like belows.
(mind you should install wanted-python-version in advance.)

# python3.6
python3 -m virtualenv venv 
virtualenv venv --python=python3.6

© 2020. All rights reserved.