您的位置 首页 知识

python自动配置环境变量 Python如何自动生成环境依赖包requirem目录生成当前 python 环境 安装的所有依赖包1、命令2、常见难题只生成当前 项目 的所有依赖包1、步骤使用 requirements.txt 安装依赖的方式拓展资料生成当前 python 环境 安装的所有依赖包1、命令cd 到项目路径下,执行下面内容命令pip freeze > requirements.txt 或者使用如下命令pip list –format=freeze > requirements.txt2、常见难题1、中使用 pip freeze > requirements.txt 命令导出已安装的模块,其中部分模块显示了 @ file:///…,而不是具体的版本号,如下图:此时,如果我们直接在其他机器上边使用 pip install -r requirements.txt 安装模块时,就会遇到如下错误:ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No suchfile or directory: ‘C:cicffi_1600699250966work’缘故这是 pip 安装软件包的一种独特语法(自19.1开始受支持)PEP404,然而该此种路径取决于环境,file:///URL 仅在本地文件体系上可用,你不能将生成的 requirements.txt 文件提供给其他人使用解决使用上述命令导出的文件中,会包含如下多少包:distribute,pip,setuptools,wheel。。。,建议手动删除!只生成当前 项目 的所有依赖包1、步骤1.1 安装 pipreqspip install pipreqs1.2 执行命令,在当前工程目录生成cd 到项目路径下,执行下面内容命令 如果已经存在requirements.txt,需要加上 –force 覆盖之 如果提示“UnicodeDecodeError: ‘gbk’ codec can’t decode ”的错误,需要指定字符集 –encoding=utf8 如果有想要忽略的目录,可以使用 –ignore <dirs> …忽略额外的目录pipreqs ./ –encoding=utf8 –force使用 requirements.txt 安装依赖的方式pip install -r requirements.txt拓展资料以上为个人经验,希望能给大家一个参考,也希望大家多多支持风君子博客。 无论兄弟们可能感兴趣的文章:Python生成requirements.txt的三种技巧Pythonpip通过requirements.txt文件安装依赖Python?requirements.txt的具体使用python?pipreqs工具生成requirements.txt文件使用详解python生成requirements.txt文件的两种技巧

版权声明

上一篇:

下一篇:


您可能感兴趣

返回顶部