文章目录

  • 步骤1:导出依赖
  • 步骤2:离线下载依赖包
  • 步骤3:进入新环境使用python安装依赖

整体思路如下:

  1. 首先根据项目需要导出依赖包,由于本地的python环境中其实安装了很多乱七八糟的包,这些包不一定都用得上,因此只需要导出必要的依赖就可以
  2. 根据当前项目的依赖清单,下载对应的安装包,以便在新的python环境中可以直接离线安装这些
  3. 进入到新环境中离线安装即可

步骤1:导出依赖

首先在当前环境下安装:pip install pipreqs,这个库可以帮助你筛选出项目需要的python包,而不是当前环境的全部依赖。安装完成后使用命令:

cd 项目根目录/
pipreqs ./ --encoding=utf-8

在根目录下会生成requirements.txt文件,我的内容如下:

itemadapter==0.1.0
selenium==3.141.0
Scrapy==2.3.0
python_dateutil==2.8.2
........

步骤2:离线下载依赖包

然后根据requirements.txt导出需要的安装包

pip download -d PIPDIR -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
  • -d指定导出的文件夹
  • -r指定根据哪一个文件导出
  • -i表示使用阿里源(当然可以使用其他国内源啊)
  • --trusted-host表示信任主机
  • 更多配置请参考:https://pip.pypa.io/en/stable/cli/pip_download/#options

有几个常用配置:

  • –platform:指定需要安装的平台,比如:linux_x86_64,如果在windows/mac上默认会下载windows/mac的安装包,在linux上是肯定安装不了的
  • –python-version:python的版本,默认与当前环境相同,如果值为3,则python版本为3.0.0, 若值为3.7,则python版本为3.7.0或3.7.3,最好根据python --version指定完整的版本号

注意:这里一定要添加--trusted-host,否则会报错:

WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement xxx==xxx (from versions: none)
ERROR: No matching distribution found for xxx==xxx

步骤3:进入新环境使用python安装依赖

根据自己的实际情况,把这个文件夹和requirements.txt移动到新的环境中,然后使用:

pip install --no-index --find-links=PIPDIR -r requirements.txt
  • --find-links就是存放安装文件的目录
  • -r是指按照requirements.txt这个文件去安装文件目录中找需要的安装包

python pip下载本地依赖包,并在离线环境中安装,并解决报错ERROR: Could not find a version that satisfies the requirement报错相关推荐

  1. pip下载包报错ERROR: Could not find a version that satisfies the requirement xxxx==1.0.2 (from versions

    我在安装pymysql的时候报错 ERROR: Could not find a version that satisfies the requirement pymysql==1.0.2 (from ...

  2. Python pip install 安装包报错ERROR: Could not find a version that satisfies the requirement XXX解决方法

    Python pip install 安装包报错ERROR: Could not find a version that satisfies the requirement XXX解决方法 文章目录 ...

  3. 【错误记录】Python 安装依赖库报错 ( ERROR: Could not find a version that satisfies the requirement elftools )

    文章目录 一.报错信息 二.解决方案 一.报错信息 报错信息 : ERROR: Could not find a version that satisfies the requirement elft ...

  4. Python安装包报错ERROR: Could not find a version that satisfies the requirement XXX解决方法

    我们在使用 pip 安装 python 包时,经常会出现如下错误: ERROR: Could not find a version that satisfies the requirement xxx ...

  5. python 导包报错:ERROR: Could not find a version that satisfies the requirement dateutil

    terminal执行脚本: pip install python-dateutil

  6. 解决Python安装pyqt5-tool出现的系列问题:ERROR: Could not find a version that satisfies the requirement xxx

    最近在做python GUI可视化编程项目,项目过程中需要使用PyQt5和QtTools资源包,因此需要使用pip install进行资源包的下载. 正常情况下安装资源包的命令如下: pip inst ...

  7. 解决pip无法安装bayes-opt报错:ERROR: Could not find a version that satisfies the requirement bayes-opt

    完整的报错是: ERROR: Could not find a version that satisfies the requirement bayes-opt ERROR: No matching ...

  8. pip安装tensorflow报错:could not find a version that satisfies the requirement grpcio=1.8.6

    下图红色字体为错误提示: - ERROR: Could not find a version that satisfies the requirement grpcio>=1.8.6 (from ...

  9. pip安装torch错误ERROR: Could not find a version that satisfies the requirement torch及解决办法

    使用pip安装PyTorch时报如下错误: ERROR: Could not find a version that satisfies the requirement torch>=1.6.0 ...

最新文章

  1. 交叉编译VIM并移植到ARM嵌入式Linux系统
  2. Swift - 程序进入后台,以及应用终止时调用的方法
  3. 【已解决】wepy中使用分包加载报错
  4. linux io读写次数 oid,Oidiomycosis in Porto Rico.
  5. yelee主题中加入revolvermaps插件
  6. VS2019优化新鲜出炉:C++后端更新汇总
  7. idea在java文件中查找_Java开发工具IntelliJ IDEA使用源代码系列教程(四):在文件中搜索目标...
  8. C++ 变量和常量
  9. 在Pocket PC/Smartphone智能设备上编写压缩程序(特别简单,任何人都能简单使用)...
  10. 北大计算机学硕几年,我的OI经历 --张正超(深学教育资深教练、北大计算机系研究生)...
  11. 华为 eNSP 模拟器安装教程(内含下载地址)
  12. 深蓝学院【视觉SLAM十四讲】汇总
  13. 《我和PIC单片机:基于PIC18》——导读
  14. 2.15 随机存取存储器与只读存储器
  15. c语言时间换算结构体9,C语言实现时区转换函数的实例
  16. 硬件探索——2FSK通信系统调制解调综合实验电路设计
  17. win10更改mysql密码_win10 修改mysql密码忘了怎么办
  18. 什么原因造成家里的WiFi网速慢?
  19. 2022年4月蓝桥杯软件类省赛:真题+解析
  20. 7-20 简单计算器

热门文章

  1. matlab createtask,Matlab批量与createjob
  2. github issue 搜索_回顾 2020 年 GitHub 的大事件,你知道多少?
  3. Unity Editor自制工具(1)--“Editor目录栏按钮+全局搜索方法+自制Editor窗口”实现搜索与删除场景中任意名称游戏物体
  4. mysql5.5从零开始_【MySQL函数】MySQL 5.5从零开始学第六章
  5. watchOS更新后 Apple Watch 4心电图功能已开始支持欧洲用户
  6. js 判断字符串的结尾的字符串
  7. 原声JS面向对象实现的简单轮播
  8. 半年之殇:困扰半年的MSP430的I2C总线问题在今天解决,发文总结
  9. ise和modelsim联合仿真的一些准备
  10. [Example of Sklearn] - Example