如何在没有网络或互联网的情况下安装 pip

如何在没有网络或互联网的情况下安装 pip

我在redhat 7.5版本上使用以下方式安装pip

我将 pkg - 下载pip-8.1.2-py2.py3-none-any.whl到没有网络的机器上

我安装它

python /root/pip-8.1.2-py2.py3-none-any.whl/pip install /root/pip-8.1.2-py2.py3-none-any.whl

但我不确定这是否是安装 pip 的正确方法?

我们尝试通过-

clone https://github.com/psf/requests.git

然后将文件复制到没有网络的机器上

然后

python setup.py install

,但是通过这种方式我得到了错误,所以我们保留它

错误在最后一行

无论如何,我们都可以看到,由于某些不清楚的原因,这种方法尝试获取互联网网络,所以我不明白为什么?

python setup.py install
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
  warnings.warn(msg)
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing requirements to requests.egg-info/requires.txt
writing requests.egg-info/PKG-INFO
writing top-level names to requests.egg-info/top_level.txt
writing dependency_links to requests.egg-info/dependency_links.txt
reading manifest file 'requests.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'NOTICE'
warning: no files found matching 'requirements.txt'
writing manifest file 'requests.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/__init__.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/__version__.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/_internal_utils.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/adapters.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/api.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/auth.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/certs.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/compat.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/cookies.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/exceptions.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/help.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/hooks.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/models.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/packages.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/sessions.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/status_codes.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/structures.py -> build/bdist.linux-x86_64/egg/requests
copying build/lib/requests/utils.py -> build/bdist.linux-x86_64/egg/requests
byte-compiling build/bdist.linux-x86_64/egg/requests/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/__version__.py to __version__.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/_internal_utils.py to _internal_utils.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/adapters.py to adapters.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/api.py to api.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/auth.py to auth.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/certs.py to certs.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/compat.py to compat.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/cookies.py to cookies.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/exceptions.py to exceptions.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/help.py to help.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/hooks.py to hooks.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/models.py to models.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/packages.py to packages.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/sessions.py to sessions.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/status_codes.py to status_codes.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/structures.py to structures.pyc
byte-compiling build/bdist.linux-x86_64/egg/requests/utils.py to utils.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying requests.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying requests.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying requests.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying requests.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying requests.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying requests.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating 'dist/requests-2.22.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing requests-2.22.0-py2.7.egg
removing '/usr/lib/python2.7/site-packages/requests-2.22.0-py2.7.egg' (and everything under it)
creating /usr/lib/python2.7/site-packages/requests-2.22.0-py2.7.egg
Extracting requests-2.22.0-py2.7.egg to /usr/lib/python2.7/site-packages
requests 2.22.0 is already the active version in easy-install.pth

Installed /usr/lib/python2.7/site-packages/requests-2.22.0-py2.7.egg
Processing dependencies for requests==2.22.0
Searching for urllib3>=1.21.1,!=1.25.0,!=1.25.1,<1.26
Reading https://pypi.python.org/simple/urllib3/
Best match: urllib3 1.25.6
Downloading https://files.pythonhosted.org/packages/ff/44/29655168da441dff66de03952880c6e2d17b252836ff1aa4421fba556424/urllib3-1.25.6.tar.gz#sha256=9a107b99a5393caf59c7aa3c1249c16e6879447533d0887f4336dde834c7be86
Processing urllib3-1.25.6.tar.gz
Writing /tmp/easy_install-WI5FBQ/urllib3-1.25.6/setup.cfg
Running urllib3-1.25.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-WI5FBQ/urllib3-1.25.6/egg-dist-tmp-tEDlGM
error: Setup script exited with error in urllib3 setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.

答案1

使用最新的 pip 版本进行回答。

下载setuptools压缩文件从这里

wget https://files.pythonhosted.org/packages/f4/d5/a6c19dcbcbc267aca376558797f036d9bcdff344c9f785fe7d0fe9a5f2a7/setuptools-41.4.0.zip

解压,更改目录然后安装:python setup.py install

下载pip 从这里:

wget https://files.pythonhosted.org/packages/ce/ea/9b445176a65ae4ba22dce1d93e4b5fe182f953df71a145f557cffaffc1bf/pip-19.3.1.tar.gz

解压,更改目录然后安装:python setup.py install

pip版本可以在这里找到点8.1.2

setuptools版本可以在这里找到安装工具 20.0.0

发行说明

相关内容