It is said that there is no network, but resources are only prepared in an environment with a network, and then installed in an environment without a network. .
1, WHL installation package
Obtain WHL file: .
1. The first method is to download directly online, providing two website addresses .
PyPI · The Python Package Index.
Python Extension Packages for Windows - Christoph Gohlke (uci. edu).
2. Using the pip package management tool .
1. Package only a single package: pip download package name - d path (PS: pip download requests - d F:/whl/) .
2. Pack multiple: .
① : Create a new file (usually required. txt) ) .
② : Edit requirements. txt (each line: registration version number) (PS: numpy 1.15.1) .
③ : pip download - d/ Whl - r requirements. txt (- d: specify save path, - r: install from given requirements)
.3. Synchronize all packages .
Pip freeze> Requirements. txt .
After executing the command, all package names and their version numbers for the current host are generated in requirements. txt .
Upload files to offline host: .
1. Single package: Upload the generated Whl file to an offline host (which may contain dependent packages, resulting in multiple Whl files) .
2. Multiple packages: Upload all files under requirements. txt and package download path./whl to the offline host .
Install WHL file: .
1. Single package: Enter the whl package file directory and execute pip install -- no index XXX.whl .
2. Multiple packages: pip install -- no index - f/ Whl - r requirements. txt (- f: find the download link for the package from the specified file, - r: install from the given requirements file) .
Verification: .
Pip list or import package name after executing Python .
2, Tar.gz installation package .
Because some packages may not have corresponding WHL package files, they can only be installed by downloading the packaged installation package: .
1. Get installation package: PyPI · The Python Package Index .
2. Upload the downloaded. tar. gz installation package to the offline host and unzip it .
3. Enter the decompression directory and locate setup.py .
4. Execute Python setup.py install for installation .
5. Verification .
3, Copying the Dharma .
Suitable for networked hosts with the same version of Python as offline hosts .
1. Using pip install XX to install the required module packages under the network .
2. Package the folder for installing packages in the Python installation directory (such as D: Python39 Lib site packages) .
3. Upload the packaged files to the offline server, decompress them, and place them in the site packages folder of the corresponding Python installation directory .
4. Verification .