How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How To Install And Use Pip And Virtualenv On CentOS 6

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
28
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Before moving on, you need to:
  2. Install and use pip
    1. Search for a Python package using pip
    2. Install a Python package using pip
    3. List Python packages installed with pip
    4. Show the details of a Python package installed with pip
    5. Upgrade a Python package using pip
    6. Uninstall a Python package using pip
    7. Display pip help
  3. Install and use virtualenv
    1. 1. Install virtualenv using pip
    2. 2. Create a dedicated virtual environment
    3. 3. Exit the virtual environment
  4. Want to contribute?


When working with Python applications, there are two important tasks to consider:

  1. How to manage Python packages.
  2. How to configure environments for Python applications.

As everyone knows, owning abundant Python application packages is the key to success for the Python community. To make the most of various Python application packages, you need a handy package manager, such as pip or easy_install. For now, the most popular Python package manager is pip.

Additionally, due to the incompatibility among different major versions of Python — 3.x, 2.7, and 2.6, as well as the resulting incompatibility among various dependencies, you should always prepare a proper environment for each of your Python applications. Virtualenv provides a feasible solution to this issue: constructing a dedicated and isolated Python environment for each of your Python applications. Every application can enjoy the most suitable Python environment without messing up other applications’ environments.

In this article, we will introduce to you how to use pip and virtualenv to manage Python packages and environments on a CentOS 6 server instance.

Before moving on, you need to:

  1. Setup a Vultr CentOS 6 x64 server instance from the ground up, and
  2. Create a non-root user who has sudo privileges and log in with it.

Install and use pip

First, let’s have a look at pip. Install the latest pip with the following commands:

sudo yum update
sudo yum install -y python-devel python-setuptools python-pip
sudo pip install --upgrade pip

Once pip has been installed, you will be able to use it to manage Python packages, including but not limited to searching for, installing, upgrading, and uninstalling Python packages. In order to give you some hands-on instructions, I will list some common pip commands below:

Search for a Python package using pip

pip search [package name]

Install a Python package using pip

a) Install a package by the package name:

sudo pip install [package name]

b) Install a specific version of a Python package:

sudo pip install [package name]==[version]

c) Install a Python package from a URL:

sudo pip install [URL]

List Python packages installed with pip

pip list

Show the details of a Python package installed with pip

pip show [package name]

Upgrade a Python package using pip

sudo pip install --upgrade [package name]

Uninstall a Python package using pip

sudo pip uninstall [package name]

Display pip help

pip help

Install and use virtualenv

As previously mentioned, the incompatibility among different dependencies is an issue worthy of your concern.

In order to avoid issues that occur due to incompatibilities, you can use virtualenv to prepare a virtual environment to contain the suitable dependencies for each of your Python applications. In this fashion, incompatible dependencies can coexist without conflict, and Python applications depending on them can coexist without conflict as well.

An additional benefit of using virtualenv is that you don’t need root/sudo privileges to modify dependencies in the virtual environment, because every operation is performed in the current user’s own directory.

Now, let’s explore the virtual environment created by virtualenv.

1. Install virtualenv using pip

sudo pip install virtualenv

2. Create a dedicated virtual environment

Before you deal with a new Python application, you can use virtualenv to create a dedicated directory—a virtualenv environment—to store your following modifications to the system dependencies.

Say that you want to use a directory “env1” under your home directory to contain the virtual environment:

cd ~
virtualenv env1

The two commands above will create the environment directory “env1” in your home directory and initiate the virtual environment in it, namely copy the global/system Python environment you are using into your virtual environment directory and adjust related configurations, making it an isolated Python environment.

Now, you need to activate the virtual environment:

source ~/env1/bin/activate

As you see, a string env1 will be inserted in front of your shell prompt, notifying you that you have entered the isolated virtual environment.

You can use the command which python to confirm your entrance. The system will tell you that you are using ~/env1/bin/python rather than the original /usr/bin/python.

From now on, you can deal with your Python application as you wish, all of your modifications to system dependencies will be recorded in this directory, avoiding the potential tampering to other Python applications.

3. Exit the virtual environment

After finishing your tasks, use the following command to exit the virtual environment:

deactivate

The string (env1) will disappear accordingly.

If you want to know more about virtualenv, use the following command:

virtualenv --help

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install BoltWire CMS on CentOS 7
CentOS

How to Install BoltWire CMS on CentOS 7

February 14, 2020
Showterm.io – A Terminal/Shell Recording, Upload and Share Tool for Linux
CentOS

Setup HTTP Authentication With Nginx on CentOS 7

February 14, 2020
Next Post

How to Install and Use CPULimit on CentOS 7

How to Install Crate.IO on CentOS 7

Install ImageMagick on CentOS 6

Leave a Reply Cancel reply

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

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How To Secure Your Nginx-Powered Website Using SSL and Secure Ciphers

3 years ago

How to Compile Nginx From Source on Fedora 25

3 years ago

Creating Network Shares Using Samba on Debian

3 years ago

How to Install Reader Self 3.5 RSS Reader on a Fedora 26 LAMP VPS

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.