Python 离线工作环境搭建的方法步骤

yipeiwu_com6年前Python基础

准备

在断网的和联网的机器安装pip,下载地址https://pypi.python.org/pypi/pip

在联网的开发机器上安装好需要的包

例如:

pip3 install paramiko
pip3 install fabric

打包已安装的包

新建pyenv文件夹用来存储下载下来的所需安装包

pip3 list #查看安装的包

#使用pip导出当前环境所有依赖包信息文件
pip3 freeze >requirements.txt

# 下载所有依赖包到本地
pip3 install -r requirements.txt -d /root/pyenv/

# pip10使用
pip download -d C:\Users\pyenv -r requirements.txt 

在其他环境下(相同的系统环境)安装所有依赖

$ pip install --no-index --find-links=/home/pyenv -r requirements.txt

Collecting asn1crypto==0.24.0 (from -r requirements.txt (line 1))
Collecting bcrypt==3.1.4 (from -r requirements.txt (line 2))
Collecting certifi==2018.4.16 (from -r requirements.txt (line 3))
Collecting cffi==1.11.5 (from -r requirements.txt (line 4))
Collecting chardet==3.0.4 (from -r requirements.txt (line 5))
Collecting cryptography==2.2.2 (from -r requirements.txt (line 6))
Requirement already satisfied: fabric==2.0.1 in /home/ap/tscms/anaconda3/lib/python3.6/site-packages/fabric-2.0.1-py3.6.egg (from -r requirements.txt (line 7))

查看已经安装的包

pip freeze

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python基础教程之自定义函数介绍

函数最重要的目的是方便我们重复使用相同的一段程序。 将一些操作隶属于一个函数,以后你想实现相同的操作的时候,只用调用函数名就可以,而不需要重复敲所有的语句。 函数的定义 首先,我们要定义...

对Python中一维向量和一维向量转置相乘的方法详解

对Python中一维向量和一维向量转置相乘的方法详解

在Python中有时会碰到需要一个一维列向量(n*1)与另一个一维列向量(n*1)的转置(1*n)相乘,得到一个n*n的矩阵的情况。但是在python中, 我们发现,无论是“.T”还是...

Windows系统下PhantomJS的安装和基本用法

Windows系统下PhantomJS的安装和基本用法

1.安装 下载网址:http://phantomjs.org/download.html 选择合适的版本。然后解压即可。 环境变量的配置: 进入解压的路径: 例如我是解压在D:\Py...

对Python _取log的几种方式小结

1. 使用.logfile 方法 #!/usr/bin/env python import pexpect import sys host="146.11.85.xxx" user=...

在Python中使用CasperJS获取JS渲染生成的HTML内容的教程

文章摘要:其实这里casperjs与python没有直接关系,主要依赖casperjs调用phantomjs webkit获取html文件内容。长期以来,爬虫抓取 客户端javascri...