Tech Deviant Navigating the 21st century - Tech, Culture and more

Creating virtual enviornment with python3

Prerequisites:

  • bash/zsh (Default shell(terminals) on Ubuntu and MAC OSX)
  • Python 3.x

The python virtual enviornment is very useful when your work(or hobby) requires you to use multiple versions of python on the same machine. It gives you a clean slate in terms of packages and you have full control of what packages are installed in that enviornment.

Below are the steps to install virtualenv and create an enviornment with python3.

Install virtualenv

$ sudo apt-get install python-virtualenv

Create a new virtualenv

$ virtualenv -p /usr/bin/python3 venv

In the above command, venv is the name of virtual enviornment. To start virtual enviornment, do this:

Start virtualenv

$ cd venv
$ source bin/activate

You can now do, $ python --version, to check the version of python in your virtual enviornment.

Stop virtualenv

$ deactivate


Comments !