如何在没有互联网连接的情况下安装 python pip?

cdh*_*hit 9 python pip

我的python是2.7.5,

-bash-4.2$ python --version
Python 2.7.5
Run Code Online (Sandbox Code Playgroud)

默认情况下它没有 python pip。

我的 Linux 是 Redhat ERHL 7.3。

-bash-4.2$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
Run Code Online (Sandbox Code Playgroud)

我还检查了 Linux 存储库中没有 python-pip 。

-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
Run Code Online (Sandbox Code Playgroud)

我安装 pip 的方法是使用get-pip.py. 我get-pip.pyhttps://packaging.python.org/installing/得到

下载链接为https://bootstrap.pypa.io/get-pip.py

我为我的 Windows 笔记本电脑下载了它,然后通过 ftp 将它上传到 Linux 服务器。

当我跑python get-pip.py。它尝试连接到 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/
Run Code Online (Sandbox Code Playgroud)

题:

  • 它连接到哪里?
  • 我可以设置私人存储库吗?
  • 是pypi回购吗?
  • 我可以为此 pypi 存储库使用静态 Web 服务器吗?
  • 如何设置 get-pip.py 以将连接指向我的私人存储库?

San*_*mar 6

如果您不想采用操作系统方式,您还可以从 PyPI 下载源存档并手动安装。

  1. 转到https://pypi.org/project/pip/#files
  2. 下载并解压存档文件。
  3. 跑步python setup.py install