Python – How to install python pip without Internet connection

pippython

My python is 2.7.5,

-bash-4.2$ python --version
Python 2.7.5

By default it doesn't have python pip.

My Linux is Redhat ERHL 7.3.

-bash-4.2$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)

I have also checked that I don't have python-pip in Linux repository.

-bash-4.2$ yum search python-pip
Loaded plugins: product-id, rhnplugin, search-disabled-repos, subscription-manager
*Note* Spacewalk repositories are not listed below. You must run this command as root to access Spacewalk repositories.
cloudera-manager                                                                                                                 7/7
Warning: No matches found for: python-pip
No matches found

My way to install pip is using get-pip.py.
I got the get-pip.py from https://packaging.python.org/installing/

The download link is https://bootstrap.pypa.io/get-pip.py

I downloaded it for my windows laptop and ftp upload it to the Linux server.

When I ran python get-pip.py.
It tried a connection to the Internet.

-bash-4.2$ python get-pip.py
Collecting pip
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x35755d0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x3575a90>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/

Question:

  • Where does it connect to?
  • Can I setup a private repository?
  • Is it pypi repo?
  • Can I use static web server for this pypi repo?
  • How can I set the get-pip.py to point the connection to my private repo?

Best Answer

If you don't want to go the OS way, you can also download the source archive from PyPI and install it manually.

  1. Go to https://pypi.org/project/pip/#files
  2. Download and extract the archive file.
  3. Run python setup.py install
Related Question