Saturday, January 9, 2021

Install pip on Python3

https://stackoverflow.com/questions/31273157/how-to-install-pip-on-compiled-from-source-python

Custom build Python might not come with pip, so you can rebuilt with the following options:

./configure --with-openssl=/usr/local/opt/openssl --with-ensurepip=install

pip need Python ssl module, which in turn need openssl.

Or,  python get-pip.py will also install pip. again, assuming Python is build with ssl module.
Download get-pip.py via:
curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py

The ensurepip package provides support for bootstrapping the pip installer into an existing Python installation or virtual environment. This bootstrapping approach reflects the fact that pip is an independent project with its own release cycle, and the latest available stable version is bundled with maintenance and feature releases of the CPython reference interpreter.

In most cases, end users of Python shouldn’t need to invoke this module directly (as pip should be bootstrapped by default), but it may be needed if installing pip was skipped when installing Python (or when creating a virtual environment) or after explicitly uninstalling pip.
python -m ensurepip

This invocation will install pip if it is not already installed, but otherwise does nothing. To ensure the installed version of pip is at least as recent as the one available in ensurepip, pass the --upgrade option:

python -m ensurepip --upgrade

By default, pip is installed into the current virtual environment (if one is active) or into the system site packages (if there is no active virtual environment).

No comments:

Post a Comment