# First get the script:curlhttps://bootstrap.pypa.io/get-pip.py-oget-pip.py# Then execute it using Python 2.7 and/or Python 3.6:python2.7get-pip.py#python3.6 get-pip.py# With pip installed you can now do things like this:pip2.7install [packagename]pip2.7install--upgrade [packagename]pip2.7uninstall [packagename]
如果系统过于陈旧,可能存在ssl证书报错:
CouldnotfetchURLhttps://pypi.org/simple/pip/:Therewasaproblemconfirmingthesslcertificate:HTTPSConnectionPool(host='pypi.org',port=443): Max retries exceeded with url: /simple/pip/ (CausedbySSLError(CertificateError("hostname 'pypi.org' doesn't match either of 'www.python.org', '*.python.org', 'docs.python.org', 'downloads.python.org', 'pypi.python.org'",),)) - skipping
# Install virtualenv for Python 2.7 and create a sandbox called "venv2"pip2.7installvirtualenv# need root privilegevirtualenvvenv2# normal user's privilege# Activate the venv2 sandbox:sourcevenv2/bin/activate# Check the Python version in the sandbox (it should be Python 2.7.14):python--version# Deactivate the sandbox:deactivate
··· You are using pip version 7.1.0, however version 21.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting pip Using cached https://files.pythonhosted.org/packages/da/f6/c83229dcc3635cdeb51874184241a9508ada15d8baa3 37a41093fab58011/pip-21.3.1.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 20, in File "/tmp/pip-build-wfciDf/pip/setup.py", line 7 def read(rel_path: str) -> str: ^ SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wfciDf/pip