Pipreqs requirements.txt 不正确
Pipreqs requirements.txt is not correct
您好,我在使用 Python 中的 pipreqs
图书馆时遇到了问题。它不会生成正确的 requirements.txt
文件。我正在使用 Python 虚拟环境,我安装的唯一软件包是 pipreqs
和 selenium
以及
pip install pipreqs
pip install selenium
项目结构:
MyProject
|- test.py
而test.py
只有一行:
from selenium import webdriver
我做的第一个
pipreqs ./
我收到错误 UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3474: character maps to <undefined>
我设法通过使用
来解决
pipreqs ./ --encoding=utf-8
但现在生成的 requirements.txt
与我的预期不符。在我看来,它应该等于:
selenium==1.341.0
但它等于:
brotli==1.0.9
cryptography==3.2.1
ipaddr==2.2.0
lxml==4.6.1
mock==4.0.2
ordereddict==1.1
protobuf==3.13.0
pyOpenSSL==19.1.0
simplejson==3.17.2
现在,当我尝试克隆此代码并执行 pip install -r requirements.txt
时,它不会安装 selenium
并且代码不会 运行。
这里发生了什么?
所以我遇到的问题是我的实际工作空间是:
MyProject
|- .venv // <- My Python Virtual Environment
|- test.py
我的 Python 虚拟环境在我的项目文件夹中,所以当我 运行 命令
pipreqs ./
它正在查看文件夹中所有文件的所有依赖项(包括我的虚拟环境),这就是它生成一个奇怪的 requirements.txt
文件的原因。
为了解决这个问题,我使用了 pipreqs 的选项 --ignore
:
pipreqs ./ --ignore .venv
而生成的requirements.txt
是:
selenium==3.141.0
您好,我在使用 Python 中的 pipreqs
图书馆时遇到了问题。它不会生成正确的 requirements.txt
文件。我正在使用 Python 虚拟环境,我安装的唯一软件包是 pipreqs
和 selenium
以及
pip install pipreqs
pip install selenium
项目结构:
MyProject
|- test.py
而test.py
只有一行:
from selenium import webdriver
我做的第一个
pipreqs ./
我收到错误 UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3474: character maps to <undefined>
我设法通过使用
pipreqs ./ --encoding=utf-8
但现在生成的 requirements.txt
与我的预期不符。在我看来,它应该等于:
selenium==1.341.0
但它等于:
brotli==1.0.9
cryptography==3.2.1
ipaddr==2.2.0
lxml==4.6.1
mock==4.0.2
ordereddict==1.1
protobuf==3.13.0
pyOpenSSL==19.1.0
simplejson==3.17.2
现在,当我尝试克隆此代码并执行 pip install -r requirements.txt
时,它不会安装 selenium
并且代码不会 运行。
这里发生了什么?
所以我遇到的问题是我的实际工作空间是:
MyProject
|- .venv // <- My Python Virtual Environment
|- test.py
我的 Python 虚拟环境在我的项目文件夹中,所以当我 运行 命令
pipreqs ./
它正在查看文件夹中所有文件的所有依赖项(包括我的虚拟环境),这就是它生成一个奇怪的 requirements.txt
文件的原因。
为了解决这个问题,我使用了 pipreqs 的选项 --ignore
:
pipreqs ./ --ignore .venv
而生成的requirements.txt
是:
selenium==3.141.0