记录下无网络时安装Python环境

一: 单独下载文件

1、下载whl离线文件到本地,放到c盘根目录(任意位置均可,只是方便安装)

https://pypi.org/

https://www.lfd.uci.edu/~gohlke/pythonlibs/(国内源,速度快。ctrl+f找到自己需要的文件)

2、 cmd到存放whl文件的目录

3、pip安装whl离线文件

pip install ****.whl

(****.whl是我们下载的whl的文件名称)

二、批量下载(使用requirements.txt文件,适用于公司为内网环境,可以先从外网下载,再拷贝到内网安装)

1、pip freeze > requirements.txt

2、配置pip(pip安装速度快的可以忽略这一步)

①在C:\Users\<你的电脑用户名>\  新建一个文件夹 pip

②在新建的pip目录新建一个 pip.ini 文件,内容如下

[global]

index-url = https://mirrors.aliyun.com/pypi/simple/
extra-index-url = https://pypi.douban.com/simple/
timeout = 120

3、(请注意cmd当前路径需包含requirements.txt文件)

先使用如下命令将包下载到本地(两条命令都需要执行,第二条命令是对第一条命令的补充),此次是下载到dir目录中

pip wheel -w DIR -r requirements.txt

pip download -d DIR -r requirements.txt

pip download --dest ./lib_data --no-deps --platform=manylinux2014_x86_64 --only-binary=:all: tensorflow

再将requirements.txt和dir目录拷贝到离线环境,再使用这条命令安装即可

pip install --no-index --find-links=DIR -r requirements.txt

如果给 pip download 命令添加选项 --platform、 --python-version、 --implementation 和 --abi 可以用于获取解释器和系统的依赖关系,而不是运行 pip 的解释器和系统的依赖关系,当添加了这些选项时,也必须同时添加 --only-binary=:all: 或 --no-deps

pip download 和 pip wheel 的区别

I'm also curious about this question and the official doc is really ambiguous.

First, with my experiment, the two commands you provided will produce the same output, and the process is quite similar.

But after I read the official doc carefully, I find some options of these two commands is different.

  • for pip download, this command is focus on download packages from somewhere, even it will also try to built it, but it will fallback to download the source packge if it can't built it. There are some options for you to filter the packages you want to download, even the packages is not compatible with your current environment. like --platform--python-version--implementation, so you can download packges for whatever interpreter you want.

  • for pip wheel, this command is focus on build a wheel for package and it's dependencies. It provide an optio --build-option, let you custom the built process. So, with this command you can only download the packages that compatible with your current interpreter and platform.

In my opinion, pip wheel is more like pip install than pip download, cause it can only "download" the packages with current interpreter.


Now for your questions:

  1. Are then the two commands equivalent? (In this case this would look like replication of instructions, not really a good design principle uncle Guido!)

Ans: For packges compatible with current interpreter, yes, they are almost equivalent, except you want some built options.

  1. How can I achieve my goal of obtaining the whls required out of my python environment and ignoring any internet 'index's?

Ans: Both command can download from local index or a local directory, but if you want packages for other platform, pip download is needed. In your situation, you may create your own index or a directory holds all packages you needed and install from there every time.

Expect more precise answers.

最新文章

  1. nyoj138 找球号(二)_离散化
  2. windows server2012 r2 上IIS8.5
  3. LeetCode - 31. Next Permutation
  4. CentOS安装XRDP实现远程桌面访问
  5. js获取get方式提交的参数返回json格式数据
  6. oracle多表查询
  7. Ubuntu安装飞鸽传输
  8. ios 添加工程依赖只能生成Generic Xcode Archive 文件原因
  9. ubantu中执行docker免sudo方法
  10. Oracle查询语句导致CPU使用率过高问题处理
  11. 下载神器(vip下载速度)
  12. js2wordcloud 词云包的使用
  13. pythonj基础(六)函数初识
  14. fiddler filter过滤+断点
  15. web.config 冲突的解决办法 (主目录子目录分别帮定域名导至出现错误)
  16. PHP之高性能I/O框架:Libevent(一)
  17. c# 正则表达式 首字母转大写
  18. erlang安装
  19. 使用ecstore-sdk开发包制作易开店和启明星模板
  20. dropload.js下拉加载更多

热门文章

  1. python实现Excel的表头与索引之间的转换
  2. MyBatis-Plus的批量处理之insertBatchSomeColumn
  3. docker、Containerd ctr、crictl 区别
  4. ubuntu18.04 安装 opencv(版本4.5.5) cmake(版本3.25)
  5. Thread记录
  6. Route路径
  7. react fiber 的运行机制
  8. uni-app配置钉钉小程序步骤
  9. Vue3学习笔记(1)
  10. ts的接口和泛型的基本语法