Installing virtualenv and virtualenvwrapper for Python3

virtualenv is a tool to create isolated Python environments.

→ This makes the assumption that your version of Python3 doesn’t come with pip3 bundled by default and you are working on a unix based environment.

Step 1 : install pip for Python3

python3 -m pip install — upgrade pip

Now, to create a virtual environment for the project that you want to work on.

Step 2 : install virtualenv

pip3 install virtualenv

Step 3 : install virtualenvwrapper

pip3 install virtualenvwrapper

→ virtualenvwrapper is a set of extensions to Ian Bicking’s virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.

Step 4 : virtualenvwrapper need environment variable

vim ~/.bashrc

append the following lines to your .bashrc file :

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=`which python3`
export VIRTUALENVWRAPPER_VIRTUALENV=`which virtualenv`
source `which virtualenvwrapper.sh`

In this environment variables, If you want virtualenvwrapper to work with different python version, then just update

export VIRTUALENVWRAPPER_PYTHON=`which python[version_number]`

or you can give the path also.

Step 5 : reload your profile

source ~/.bashrc

Installation setup Done.

→ Basic commands :

1. Created virtual environment :

virtualenv -p $(which python3) name_myenv

here, [ -p ] option is to select the python interpreter version.

[ name_myenv ] is the name which you would like to give to the virtual environment.

Alternative to create virtual environment :

mkvirtualenv --python=python3 name_myenv2

This command will create the virtual environment with python 3 interpreter and make it activate at the same time.

2. Enter in virtual environment :

source name_myenv/bin/activate

3. Exit form virtual environment :

deactivate

4. To delete environment :

rm -rf name_myenv

5. List all virtual environment :

lsvirtualenv

NOTE : lsvirtualenv is a part of virtualenvwrapper.

connect me on :

Linkedin

--

--

--

2x Red Hat Certified Engineer | Aspiring MLOps & DevOps Engineer | Terraform | Ansible | Jenkins | AWS • GCP • Azure | OpenShift | Kubernetes | Docker | BigData

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Minerva Wallet: All you need to know

Serverless take 2: AWS CDK and AWS Cognito

Fantastic Tips For The Julia REPL

When To Say Goodbye To Your Legacy Software

Strategic Partnership with X Protocol

| Engineering News-Record

Secrets Manager vs. Parameter Store

Install Let’s encrypt in a Shared Hosting like GoDaddy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rahulkumar Choudhary

Rahulkumar Choudhary

2x Red Hat Certified Engineer | Aspiring MLOps & DevOps Engineer | Terraform | Ansible | Jenkins | AWS • GCP • Azure | OpenShift | Kubernetes | Docker | BigData

More from Medium

SAFU NETWORK

Getting to 1000 ELO on chess.com

3D Scanning on an iPhone Pro: can it be a serious tool for VFX? — Part 2

Demon Party: Dragonfall