python3离线安装第三方模块及其依赖包

Python010

python3离线安装第三方模块及其依赖包,第1张

以管理员权限启动cmd命令窗口,执行pip命令安装所需要的模块。例如:

以管理员权限启动cmd命令窗口,执行以下命令打包pip第三方安装包及安装索引。

将 packages 文件夹和 requirements.txt 文件拷贝至离线机器任意同级目录下,以管理员权限启动cmd命令窗口进入该目录,执行下述命令进行离线安装。

按照部署1、2、3导出外网机python环境list,可以批量安装python第三方依赖。若只需安装一个python包,可以使用下属方法:

通过pip来安装python模块

安装 easy_install pip

D:\work>easy_install pip 

Searching for pip 

Best match: pip 6.1.1

Processing pip-6.1.1-py2.7.egg

pip 6.1.1 is already the active version in easy-install.pth 

Installing pip-script.py script to C:\Python27\Scripts 

Installing pip.exe script to C:\Python27\Scripts 

Installing pip2.7-script.py script to C:\Python27\Scripts 

Installing pip2.7.exe script to C:\Python27\Scripts 

Installing pip2-script.py script to C:\Python27\Scripts 

Installing pip2.exe script to C:\Python27\Scripts 

  

Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg

Processing dependencies for pip 

Finished processing dependencies for pip

运行 pip install xlrd

Usage:   

 pip <command> [options] 

  

Commands: 

 install           Install packages. 

 uninstall          Uninstall packages. 

 freeze           Output installed packages in requirements format. 

 list            List installed packages. 

 show            Show information about installed packages. 

 search           Search PyPI for packages. 

 wheel            Build wheels from your requirements. 

 zip             DEPRECATED. Zip individual packages. 

 unzip            DEPRECATED. Unzip individual packages. 

 help            Show help for commands. 

  

General Options: 

 -h, --help         Show help. 

 --isolated         Run pip in an isolated mode, ignoring 

               environment variables and user configuration. 

 -v, --verbose        Give more output. Option is additive, and can be 

               used up to 3 times. 

 -V, --version        Show version and exit. 

 -q, --quiet         Give less output. 

 --log <path>        Path to a verbose appending log. 

 --proxy <proxy>       Specify a proxy in the form 

               [user:passwd@]proxy.server:port. 

 --retries <retries>     Maximum number of retries each connection should 

               attempt (default 5 times). 

 --timeout <sec>       Set the socket timeout (default 15 seconds). 

 --exists-action <action>  Default action when a path already exists: 

               (s)witch, (i)gnore, (w)ipe, (b)ackup. 

 --trusted-host <hostname>  Mark this host as trusted, even though it does 

               not have valid or any HTTPS. 

 --cert <path>        Path to alternate CA bundle. 

 --client-cert <path>    Path to SSL client certificate, a single file

               containing the private key and the certificate 

               in PEM format. 

 --cache-dir <dir>      Store the cache data in <dir>. 

 --no-cache-dir       Disable the cache. 

 --disable-pip-version-check 

               Don't periodically check PyPI to determine 

               whether a new version of pip is available for

               download. Implied with --no-index.