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