python3 requirements.txt文件显示不需要的包

问题描述 投票:1回答:1

我使用:python3 -m venv .创建了一个虚拟环境然后我使用命令pip freeze requirements.txt来获取包列表。

以下是文件requirements.txt的内容

apsw==3.16.2.post1
asn1crypto==0.24.0
beautifulsoup4==4.6.0
chardet==3.0.4
CherryPy==8.9.1
configparser==3.5.0
cryptography==2.1.4
cssselect==1.0.3
cssutils==1.0.2
dnspython==1.15.0
enum34==1.1.6
feedparser==5.2.1
flake8==3.5.0
html5-parser==0.4.4
html5lib==0.999999999
idna==2.6
ipaddress==1.0.17
jedi==0.11.1
keyring==10.6.0
keyrings.alt==3.0
lxml==4.2.1
Markdown==2.6.9
mccabe==0.6.1
mechanize==0.2.5
msgpack==0.5.6
mysql-connector-python==8.0.6
mysql-utilities==1.6.4
netifaces==0.10.4
numpy==1.14.5
olefile==0.45.1
paramiko==2.0.0
parso==0.1.1
pep8==1.7.1
pexpect==4.2.1
Pillow==5.1.0
pyasn1==0.4.2
pycodestyle==2.3.1
pycrypto==2.6.1
pyflakes==1.6.0
Pygments==2.2.0
pygobject==3.26.1
pyodbc==4.0.17
pyOpenSSL==17.5.0
pyparsing==2.2.0
pysqlite==2.7.0
python-dateutil==2.6.1
pyxdg==0.25
PyYAML==3.12
regex==2017.12.12
repoze.lru==0.7
Routes==2.4.1
SecretStorage==2.3.1
simplejson==3.13.2
six==1.11.0
unity-lens-photos==1.0
uTidylib==0.3
virtualenv==15.2.0
webencodings==0.5
WebOb==1.7.3

我不确定该项目需要哪些包。项目似乎不需要大部分软件包。为什么requirements.txt会显示这么多包?如何解决这个问题,以便requirements.txt显示特定项目所需的软件包列表?(我可以手动删除它们,但为什么它们首先显示在requirements.txt中?)

注意:以前我曾经用sudo apt-get install python3-package-name安装软件包。这是否导致永久安装软件包并在通过python -m venv .创建的虚拟环境中重复出现?或者是这些默认和强制包?

操作系统:ubuntu 18.04,python版本:3.6.5,pip版本:9.0.1

python python-3.x pip requirements.txt python-venv
1个回答
0
投票

这是使用pip和requirements.txt管理包的典型问题。新的Pipenv项目通过从开发角度制作一个包含您实际使用的包的所有依赖关系的“lockfile”来解决这个问题。这在Bundler和npm等其他语言的包管理器中很常见。

因此,如果此requirements.txt变得太难以管理,我建议迁移到Pipenv。

© www.soinside.com 2019 - 2024. All rights reserved.