How to install pip and python Virtual Environment virtualenv in Ubuntu

Source: Internet
Author: User

How to install pip and python Virtual Environment virtualenv in Ubuntu

In ubuntu, although Python 2 is provided, there is no pip. I encountered some problems during the recent installation of pip and tried many methods on the Internet. Such as sudo apt install python3-pip

However, if you have tried it, there are still problems.

I have figured out some methods, which are effective for my tests.

(1) download pip

(2) unzip and install

Input tar-xf pip-9.0.1.tar.gz

Enter

Sudo python3 setup. py install

Test:

Pip-v

Install the python Virtual Environment virtualenv

Virtualenv is a tool used to create an isolated Python environment. Virtualenv creates a folder containing all the necessary executable files to use the packages required by the Python project.

Pip install virtualenv

Create a virtual environment

Mkdir [virtual environment directory]

Virtualenv -- no-site-packages-p [python path] [Virtual Environment name]

-- The no-site-packages parameter is used to create an independent python environment.

Start the Virtual Environment

Source (Virtual Environment name)/bin/activate

To install it in a virtual environment, you must enter the corresponding virtual environment.

./Pip install [installation package name] or sudo./pip install [installation package name]

./Pip is to run pip in the current directory for Installation

Exit the Virtual Environment

Deactivate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.