一般公司的服务器都是和外网隔离的,这个如果没有内部pip源的话,想要安装python的模块就需要去python官网一个一个下载依赖模块的包,然后逐个安装,这样做非常耗时间。

我们今天用的办法就是现在我们能够连接公网的linux机器上面先使用pip命令安装好我们需要的python模块。然后再将需要的模块一键下载并拷贝到服务器上一键安装。步骤如下:

前提条件:

  如果服务器是linux的,我们就需要一个能连公网的linux,不能使用windows是因为,有很多模块linux和windows两个平台不是共用的,在安装的时候会报错。

步骤:

1、在能连接公网的linux机器上使用pip命令安装好需要的模块。(pip安装的好处是:会自动帮你把依赖模块安装好)

pip3 install -i https://mirrors.aliyun.com/pypi/simple/ sh
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ docker-py
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ fabric
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ paramiko
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ psutil
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ PyMySQL
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ redis
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ requests
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ selenium
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ SQLAlchemy
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ tornado
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ xlrd
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ xlwt
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ xmltodict
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ celery
pip3 install -i https://mirrors.aliyun.com/pypi/simple/ celery-flower

2、然后在能连接公网的机器上执行pip freeze>python3_module.txt,这样就可以将你之前安装的模块列表导出来

3、列表导出来以后就需要根据这个列表去把模块的代码文件从公网下载下来,执行mkdir python3_package && pip3 download -r python3_modules.txt -d python3_packages/ -i https://mirrors.aliyun.com/pypi/simple/  ,这里我们使用了阿里的源,这样下载的速度会快很多

4、将下载完的文件夹打包,mv python3_modules.txt python3_packages/ && tar -czf python3_packages.tar.gz python3_packages,然后将打包完的文件上传到服务器上解压,tar -xzf python3_packages.tar.gz。

5、在服务器上安装我们的模块(前提需要安装和能连接公网的linux机器版本相同的python),cd python3_packages && /opt/samp/venv/python3/bin/pip3 install --no-index --find-links=file:. -r python3_modules.txt,等待安装完成即可,这样可以避免让人奔溃的依赖模块一个一个安装问题。

[root@itsasitapp213 python3_packages]# /opt/samp/venv/python3/bin/pip3 install --no-index --find-links=file:. -r python3_modules.txt
Looking in links: file:.
Collecting amqp==2.4. (from -r python3_modules.txt (line ))
Collecting asn1crypto==0.24. (from -r python3_modules.txt (line ))
Collecting Babel==2.6. (from -r python3_modules.txt (line ))
Collecting bcrypt==3.1. (from -r python3_modules.txt (line ))
Collecting billiard==3.5.0.5 (from -r python3_modules.txt (line ))
Collecting celery==4.2. (from -r python3_modules.txt (line ))
Collecting celery-flower==1.0. (from -r python3_modules.txt (line ))
Collecting certifi==2018.11. (from -r python3_modules.txt (line ))
Collecting cffi==1.12. (from -r python3_modules.txt (line ))
Collecting chardet==3.0. (from -r python3_modules.txt (line ))
Collecting cryptography==2.6. (from -r python3_modules.txt (line ))
Collecting docker-py==1.10. (from -r python3_modules.txt (line ))
Collecting docker-pycreds==0.4. (from -r python3_modules.txt (line ))
Collecting fabric==2.4. (from -r python3_modules.txt (line ))
Collecting idna==2.8 (from -r python3_modules.txt (line ))
Collecting invoke==1.2. (from -r python3_modules.txt (line ))
Collecting kombu==4.4. (from -r python3_modules.txt (line ))
Collecting paramiko==2.4. (from -r python3_modules.txt (line ))
Collecting psutil==5.6. (from -r python3_modules.txt (line ))
Collecting pyasn1==0.4. (from -r python3_modules.txt (line ))
Collecting pycparser==2.19 (from -r python3_modules.txt (line ))
Collecting PyMySQL==0.9. (from -r python3_modules.txt (line ))
Collecting PyNaCl==1.3. (from -r python3_modules.txt (line ))
Collecting pytz==2018.9 (from -r python3_modules.txt (line ))
Collecting redis==3.2. (from -r python3_modules.txt (line ))
Collecting requests==2.21. (from -r python3_modules.txt (line ))
Collecting selenium==3.141. (from -r python3_modules.txt (line ))
Collecting sh==1.12. (from -r python3_modules.txt (line ))
Collecting six==1.12. (from -r python3_modules.txt (line ))
Collecting SQLAlchemy==1.3. (from -r python3_modules.txt (line ))
Collecting tornado==6.0. (from -r python3_modules.txt (line ))
Collecting urllib3==1.24. (from -r python3_modules.txt (line ))
Collecting vine==1.2. (from -r python3_modules.txt (line ))
Collecting websocket-client==0.55. (from -r python3_modules.txt (line ))
Collecting xlrd==1.2. (from -r python3_modules.txt (line ))
Collecting xlwt==1.3. (from -r python3_modules.txt (line ))
Collecting xmltodict==0.12. (from -r python3_modules.txt (line ))
Installing collected packages: vine, amqp, asn1crypto, pytz, Babel, six, pycparser, cffi, bcrypt, billiard, kombu, celery, tornado, celery-flower, certifi, chardet, cryptography, websocket-client, docker-pycreds, urllib3, idna, requests, docker-py, invoke, pyasn1, PyNaCl, paramiko, fabric, psutil, PyMySQL, redis, selenium, sh, SQLAlchemy, xlrd, xlwt, xmltodict
Running setup.py install for pycparser ... done
Running setup.py install for billiard ... done
Running setup.py install for tornado ... done
Running setup.py install for celery-flower ... done
Running setup.py install for psutil ... done
Running setup.py install for SQLAlchemy ... done
Successfully installed Babel-2.6. PyMySQL-0.9. PyNaCl-1.3. SQLAlchemy-1.3. amqp-2.4. asn1crypto-0.24. bcrypt-3.1. billiard-3.5.0.5 celery-4.2. celery-flower-1.0. certifi-2018.11. cffi-1.12. chardet-3.0. cryptography-2.6. docker-py-1.10. docker-pycreds-0.4. fabric-2.4. idna-2.8 invoke-1.2. kombu-4.4. paramiko-2.4. psutil-5.6. pyasn1-0.4. pycparser-2.19 pytz-2018.9 redis-3.2. requests-2.21. selenium-3.141. sh-1.12. six-1.12. tornado-6.0. urllib3-1.24. vine-1.2. websocket-client-0.55. xlrd-1.2. xlwt-1.3. xmltodict-0.12.

离线方式快速安装python模块以及相关依赖模块的更多相关文章

  1. 在Ubuntu上使用离线方式快速安装K8S v1.11.1

    在Ubuntu上使用离线方式快速安装K8S v1.11.1 0.安装包文件下载 https://pan.baidu.com/s/1nmC94Uh-lIl0slLFeA1-qw v1.11.1 文件大小 ...

  2. 第三百二十三节,web爬虫,scrapy模块以及相关依赖模块安装

    第三百二十三节,web爬虫,scrapy模块以及相关依赖模块安装 当前环境python3.5 ,windows10系统 Linux系统安装 在线安装,会自动安装scrapy模块以及相关依赖模块 pip ...

  3. 二 web爬虫,scrapy模块以及相关依赖模块安装

    当前环境python3.5 ,windows10系统 Linux系统安装 在线安装,会自动安装scrapy模块以及相关依赖模块 pip install Scrapy 手动源码安装,比较麻烦要自己手动安 ...

  4. 二进制方式快速安装MySQL数据库命令集合

    二进制方式快速安装MySQL数据库命令集合 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1.安装mysql ls mysql ...

  5. CentOS RDO方式快速安装OpenStack

    一.了解RDO RDO是什么? RDO是红帽Red Hat Enterprise Linux OpenStack Platform的社区版,类似RHEL和Fedora,RHEV和oVirt这样的关系. ...

  6. Windows安装Python图像处理库:PIL模块

    平常一般都在Linux下用Python,今天女票突然说让帮忙把一些图片全部弄成一个分辨率的,作为程序员,这种重复的工作还是交给计算机吧. 废话不多说,打开Cmd看下Windows的python下面是否 ...

  7. CentOS 7 yum方式快速安装MongoDB

    一.安装环境及配置yum # more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # vi /etc/yum.repos.d/m ...

  8. Linux - CentOS 7 yum方式快速安装MongoDB

    一.安装环境及配置yum # more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # vi /etc/yum.repos.d/m ...

  9. PHP安装扩展mcrypt以及相关依赖项 【PHP安装PECL扩展的方法】

    一:Mcrypt简介 Mcrypt是PHP的一个扩展,完成了常用加密算法的封装.其实该扩展是对mcrypt标准类库的封装,mcrypt完成了相当多的常用加密算法,如DES, TripleDES, Bl ...

随机推荐

  1. make CMake 来龙去脉

    理论上说,任意一个C++程序都可以用g++来编译. 大家都知道,写程序大体步骤如下: 1.用编辑器编写源代码,如.c文件. 2.用编译器编译代码生成目标文件,如.o. 3.用链接器连接目标代码生成可执 ...

  2. 隐马尔科夫模型(Hidden Markov Models) 系列之一

    转自:http://blog.csdn.net/eaglex/article/details/6376826 介绍(introduction) 通常我们总是对寻找某一段时间上的模式感兴趣,这些模式可能 ...

  3. android 调试崩溃Unable to instantiate application的解决方法

    E/AndroidRuntime: FATAL EXCEPTION: main                   Process: com.***.plants, PID: 23100        ...

  4. WorkFlow三:配BO对象,事件触发工作流

    1.新建个BO对象的字段. 2.新建取数函数: 3.运行事物代码SWO1新建BO对象. 4.新建关键字段: 5.新建BO对象的事件: 6.添加处理方法: 6.调整对象状态,这里是本地对象,不需要释放, ...

  5. Ambari 管理hadoop、hbase、zookeeper节点

    简介: Apache Ambari是一种基于Web的工具,支持Apache Hadoop集群的供应.管理和监控.Ambari已支持大多数Hadoop组件,包括HDFS.MapReduce.Hive.P ...

  6. Zabbix 添加内存告警

    1.在Template OS Linux模板创建item Configuration-->Templates-->Template OS Linux-->items-->cre ...

  7. Linux shell简单创建用户脚本

    前面介绍简单的shell编写规则. 现在开始编写一个简单的shell脚本. Linux shell介绍 编写shell脚本    1.创建脚本文件    2.根据需求,编写脚本    3.测试执行脚本 ...

  8. CDH6.1.1阿里云安装实践

    概念介绍 CDH概览 CDH是Apache Hadoop和相关项目的最完整.最受测试和最流行的发行版.CDH提供Hadoop的核心元素-可伸缩存储和分布式计算-以及基于web的用户界面和重要的企业功能 ...

  9. 【Linux】查看程序是否正常运行

    ps aux|grep redis-server ps -ef |grep redis netstat -tunple|grep 6379 netstat -lntp | grep 6379

  10. restql 学习二 几种查询模式

    restql 提供了比较强大的查询处理. 支持的几种查询模式 基本查询,主要是单一映射资源的查询,(from,with,only,header,cache...) 并行查询,多个资源的同时查询,(对于 ...