How to install new python package using PIP


In this tutorial, How to Setup a Python Virtual Environment. I will Install New Python package for the test environment.

In preview post, I have installed and configure basic PIP here

Activate Your Virtual Environment

source venv/bin/activate

You can see “(venv)” indicator at the beginning of your command prompt.

(Test_Environment) [devopsroles@server1 ~]$

At any time, you can stop your virtual environment using the deactivate command.

(Test_Environment) [devopsroles@server1 ~]$ deactivate
[devopsroles@server1 ~]$ 

Install Packages

[devopsroles@server1 ~]$ pip3 freeze > package.txt
[devopsroles@server1 ~]$ python3 -m venv Test_Environment
[devopsroles@server1 ~]$ source Test_Environment/bin/activate
(Test_Environment) [devopsroles@server1 ~]$ pip install flask==1.0.0
(Test_Environment) [devopsroles@server1 ~]$ pip freeze > package_after.txt

After, install flask package in Test_Environmet as below

(Test_Environment) [devopsroles@server1 ~]$ ll
total 8
-rw-rw-r--. 1 devopsroles devopsroles  93 Sep  3 21:21 package_after.txt
-rw-rw-r--. 1 devopsroles devopsroles 297 Sep  3 21:20 package.txt
drwxrwxr-x. 5 devopsroles devopsroles 100 Sep  3 21:21 Test_Environment

You can difference confirmation as the picture below

Now, you can install everything package for another developer could easily recreate your environment and run code

git clone
cd /home/huupv
source venv/bin/activate
pip install -r requirements.txt


You can install a new python package using PIP for a Virtual environment. I hope will this your helpful. Thank you for reading the DevopsRoles page!


About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.