离线方式快速安装python模块以及相关依赖模块
一般公司的服务器都是和外网隔离的,这个如果没有内部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模块以及相关依赖模块的更多相关文章
- 在Ubuntu上使用离线方式快速安装K8S v1.11.1
在Ubuntu上使用离线方式快速安装K8S v1.11.1 0.安装包文件下载 https://pan.baidu.com/s/1nmC94Uh-lIl0slLFeA1-qw v1.11.1 文件大小 ...
- 第三百二十三节,web爬虫,scrapy模块以及相关依赖模块安装
第三百二十三节,web爬虫,scrapy模块以及相关依赖模块安装 当前环境python3.5 ,windows10系统 Linux系统安装 在线安装,会自动安装scrapy模块以及相关依赖模块 pip ...
- 二 web爬虫,scrapy模块以及相关依赖模块安装
当前环境python3.5 ,windows10系统 Linux系统安装 在线安装,会自动安装scrapy模块以及相关依赖模块 pip install Scrapy 手动源码安装,比较麻烦要自己手动安 ...
- 二进制方式快速安装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 ...
- CentOS RDO方式快速安装OpenStack
一.了解RDO RDO是什么? RDO是红帽Red Hat Enterprise Linux OpenStack Platform的社区版,类似RHEL和Fedora,RHEV和oVirt这样的关系. ...
- Windows安装Python图像处理库:PIL模块
平常一般都在Linux下用Python,今天女票突然说让帮忙把一些图片全部弄成一个分辨率的,作为程序员,这种重复的工作还是交给计算机吧. 废话不多说,打开Cmd看下Windows的python下面是否 ...
- CentOS 7 yum方式快速安装MongoDB
一.安装环境及配置yum # more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # vi /etc/yum.repos.d/m ...
- Linux - CentOS 7 yum方式快速安装MongoDB
一.安装环境及配置yum # more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # vi /etc/yum.repos.d/m ...
- PHP安装扩展mcrypt以及相关依赖项 【PHP安装PECL扩展的方法】
一:Mcrypt简介 Mcrypt是PHP的一个扩展,完成了常用加密算法的封装.其实该扩展是对mcrypt标准类库的封装,mcrypt完成了相当多的常用加密算法,如DES, TripleDES, Bl ...
随机推荐
- maven 学习---Maven教程
Apache Maven是一个软件项目管理和综合工具.基于项目对象模型(POM)的概念,Maven可以从一个中心资料片管理项目构建,报告和文件. 本教程将介绍如何使用Maven在Java开发,或任何其 ...
- 【MySQL】rds 不支持镜像表/联合表,怎么办?
出于对业务的不了解,往往会让人做出错误的判断 CREATE TABLE `new_tables` ( `customer_id` int(11) NOT NULL AUTO_INCREMENT C ...
- nginx 配置相关解析
nginx模块处理流程一般是这样的: 客户端发送HTTP请求 –> Nginx基于配置文件中的位置选择一个合适的处理模块 ->(如果有)负载均衡模块选择一台后端服务器 –> 处理模块 ...
- Linux的rpm管理
书山有路勤为径,学海无涯苦作舟 自学linux已经有几天了,感觉还可以.坚持下去,就会有收获. 每个系统都用相应的软件的管理,Linux也不例外.下面讲 ...
- 压缩,解压缩 和tar详细介绍
文件压缩/解压缩 gzip bzip2 xz 只能压缩文件,不能压缩文件夹(压缩完后,文件会消失) 先建三个文件来进行演示 touch ./{1..3}.txt 文件已经创建好,下面就开始介 ...
- 【GPU加速系列】PyCUDA(一):上手简单操作
PyCUDA 可以通过 Python 访问 NVIDIA 的 CUDA 并行计算 API. 具体介绍和安装可以参考 PyCUDA 官网文档和 pycuda PyPI. 本文涵盖的内容有: 通过 PyC ...
- 实时通讯之Socket.io
WebSocket WebSocket是HTML5开始提供的一种浏览器与服务器间进行全双工通讯的网络技术.使用WebSocket,浏览器和服务器只需要要做一个握手的动作,然后,浏览器和服务器之间就形成 ...
- python网页内容提取神器lxml
一.Xpath是什么 XPath 是一门在 XML 文档中查找信息的语言.XPath 用于在 XML 文档中通过元素和属性进行导航. XPath 使用路径表达式在 XML 文档中进行导航 XPath ...
- django 导出xls文件
1.同目录下创建file_handle.py文件 file_handle.py import xlwt, datetime from xlwt import * import xlsxwriter # ...
- 12 opencv图像合成
#include < stdio.h > #include < opencv2\opencv.hpp > #include < opencv2\stitching.hpp ...