- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python bootstrapping the pip installer
In addition to the modules and packages built in to the standard distribution of Python, large number of packages from third party developers are uploaded to Python package repository called Python Package Index (https://pypi.org/. To install packages from here, pip utility is needed. The pip tool is an independent project, but since Python 3.4, it has been bootstrapped in Python distribution.
The ensurepip module provides support for bootstrapping pip in existing installation of Python. Normally user doesn't need to use it explicitly. If however, installation of pip is skipped in normal installation or virtual environment, it may be needed.
Following command will create a virtual environment without pip utility being installed.
C:\python37>python -m venv --without-pip e:\testenv
The scripts folder under the virtual environment directory doesn't contain pip utility. The ensurepip module is now used to incorporate pip in it using its version in system wide installation. Specify '--upgrade' for its latest version
E:\testenv>scripts\python -m ensurepip --upgrade Looking in links: C:\Users\acer\AppData\Local\Temp\tmpp1bb2lym Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-18.1 setuptools-40.6.2
Default installation of pip can be modified by following options
--root <dir> − Installs pip relative to the given root directory rather than the root of the currently active virtual environment (if any) or the default root for the current Python installation.
--user − Installs pip into the user site packages directory rather than globally for the current Python installation (this option is not permitted inside an active virtual environment).
The ensurepip module also defined following functions
ensurepip.version() − Returns a string specifying the bundled version of pip that will be installed when bootstrapping an environment.
ensurepip.bootstrap() − Bootstraps pip into the current or designated environment.
The bootstrapping process has side effects on both sys.path and os.environ. Also, the bootstrapping process may install additional modules required by pip, but other software should not assume those dependencies will always be present by default
Kickstart Your Career
Get certified by completing the courseGet Started