Howtodojo logo
  • Home 
  • About 
  • Certifications 
  • Sample Database 
  • Cheatsheet 
  • Glossary 
  • Blog 
  • Tags 
  1.   Blog
  1. Home
  2. Blog
  3. How To Install Virtualenv On Ubuntu 16.04

How To Install Virtualenv On Ubuntu 16.04

Share via
Howtodojo
Link copied to clipboard

In this tutorial we learn how to install virtualenv on ubuntu 16.04. We will also learn how to activate, installl package and deactivate virtualenv.

On this page
Overview   Prerequisites   Step 1 – Install Virtualenv On Ubuntu 16.04   Using virtualenv on Ubuntu 16.04   Check virtualenv version and path   Create new virtualenv on Ubuntu 16.04   Activate Virtualenv   Install packages inside virtualenv   Deactivate virtualenv   Summary  

Overview  

In this tutorial, we learn how to install Python Virtualenv on Ubuntu 16.04.

Virtualenv is a tool to create isolated Python environment. It will create a directory that contains all the necessary executables to the packages that a Python project would need.

Prerequisites  

This tutorial assumes that you already have pip installed on your Ubuntu 16.04.

Step 1 – Install Virtualenv On Ubuntu 16.04  


sudo pip install virtualenv

That’s it. Installing virtualenv only have 1 step. Now let’s learn how to use virtualenv.

Using virtualenv on Ubuntu 16.04  

Check virtualenv version and path  

To check the virtualenv version installed, we can use the command below.


$ virtualenv --version
virtualenv 20.0.16 from /usr/local/lib/python3.5/dist-packages/virtualenv/__init__.py

To check virtualenv path we can use the command below


$ which virtualenv 
/usr/local/bin/virtualenv

Create new virtualenv on Ubuntu 16.04  

To create new virtualenv we just need to pass the virtualenv name. This name will also be used as the directory name of the virtualenv. The command below will create new virtualenv named getip


virtualenv getip

Activate Virtualenv  

To activate virtualenv we can use source to load the virtualenv. The path pattern will be (virtualenvname)/bin/activate


source getip/bin/activate

Of course, we can also use . to load the virtualenv


. getip/bin/activate

Install packages inside virtualenv  

In this tutorial, we install requests packages as an example


pip install requests

Now let’s check whether the requests packages already installed by listing all packages

Deactivate virtualenv  

To deactivate current virtualenv we can use the command below.


deactivate

Now when we list all pip packages installed it will also show request but the version is different.


pip list

This shows that the requests package installed inside virtualenv is not affecting the package already installed on the system.

Summary  

In this tutorial, we learn how to install Python Virtualenv on Ubuntu 16.04. We also learn how to use virtualenv on ubuntu 16.04

 How To Install XCode Command Line Tools
How to Use pgbadger for AWS RDS Logs 
On this page:
Overview   Prerequisites   Step 1 – Install Virtualenv On Ubuntu 16.04   Using virtualenv on Ubuntu 16.04   Check virtualenv version and path   Create new virtualenv on Ubuntu 16.04   Activate Virtualenv   Install packages inside virtualenv   Deactivate virtualenv   Summary  
Follow me

We publish tutorials, tips and tricks about Linux, open source, cloud computing, and infrastructure

     
Copyright © 2012 - 2025 howtodojo.com. |
Howtodojo
Code copied to clipboard