![如何在没有互联网连接的情况下安装 python pip?](https://linux22.com/image/110715/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%B2%A1%E6%9C%89%E4%BA%92%E8%81%94%E7%BD%91%E8%BF%9E%E6%8E%A5%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E5%AE%89%E8%A3%85%20python%20pip%EF%BC%9F.png)
我的Python是2.7.5,
-bash-4.2$ python --version
Python 2.7.5
默认情况下它没有 python pip。
我的 Linux 是 Redhat ERHL 7.3。
-bash-4.2$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
我还检查了 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
我安装 pip 的方法是使用get-pip.py
.我得到了get-pip.py
来自https://packaging.python.org/installing/
下载链接是https://bootstrap.pypa.io/get-pip.py
我为我的 Windows 笔记本电脑下载了它,然后通过 ftp 将其上传到 Linux 服务器。
当我跑的时候python get-pip.py
。它尝试连接到互联网。
-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/
问题:
- 它连接到哪里?
- 我可以设置私人存储库吗?
- 是 pypi 仓库吗?
- 我可以为此 pypi 存储库使用静态 Web 服务器吗?
- 如何设置 get-pip.py 将连接指向我的私人存储库?
答案1
如果您不想采用操作系统方式,您还可以从 PyPI 下载源存档并手动安装。
- 去https://pypi.org/project/pip/#files
- 下载并解压存档文件。
- 跑步
python setup.py install