10

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?
5
  • From where did you obtain get-pip.py? The version I found has a base85 blob representing a zip file at the end, though just downloading from the source seems much more reasonable
    – Fox
    May 2, 2017 at 4:14
  • @Fox, I added the download link into my question details.
    – cdhit
    May 2, 2017 at 4:33
  • 1
    pip is in the EPEL repository, if you can add that, use it.
    – muru
    May 2, 2017 at 4:51
  • 2
    Edit get-pip.py, changing with open(pip_zip, "wb") as fp to with open ("pip.zip", "wb") as fp. Remove bootstrap(tmpdir=tmpdir). Run it, unzip pip.zip, and copy the new pip directory to /usr/lib/pythonX.Y or wherever your system keeps Python libraries. I'm not posting this as an answer because I consider it "hackish" and bad
    – Fox
    May 2, 2017 at 5:38
  • 1
    If you have recent enough version of Python, you may be able to use ensurepip.
    – Lie Ryan
    Nov 10, 2020 at 10:55

3 Answers 3

6

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
3

Download the .rpm from EPEL repo and install using yum command.

https://dl.fedoraproject.org/pub/epel/7Server/x86_64/Packages/p/python2-pip-8.1.2-8.el7.noarch.rpm

1

If you have recent enough version of Python (3.4 or higher), you may be able to use ensurepip.

ensurepip does not contact PyPI, but instead rely on a private copy of pip stored inside the standard library (src).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .