安装软件包时,pipenv不显示进度条

2024-04-18 02:56:06 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试使用pipenv安装软件包时,进度条不会显示。这对我来说非常重要,因为我的数据连接有限,我需要提前知道我下载的软件包的大小。 这是我在pipenv得到的一个例子

pipenv install spacy
Installing spacy...
[   =] Installing spacy...  

这是我在安装带有普通pip的软件包时得到的结果

pip install spacy
Collecting spacy
  Downloading spacy-3.0.1-cp39-cp39-win_amd64.whl (11.4 MB)
     |████████████                    | 4.3 MB 2.2 MB/s eta 0:00:04

有没有办法用pipenv显示进度条?像tutorials这样的东西上的其他人都可以显示进度条,而无需额外的代码。也许在新版本中,它不是显示进度条的默认设置

我确实有办法知道软件包的大小,我只需执行pip安装,检查大小,然后立即中止,这样我就可以进行pipenv安装


Tags: installpip数据进度条spacypipenvmbwin
1条回答
网友
1楼 · 发布于 2024-04-18 02:56:06

目前,pipenv无法显示与pip相同的下载进度条。早在2018年7月就有人在这里请求过它:pipenv couldn't display progress bar when it downloads package,该功能请求仍然是开放的

I mean, sometimes when we want to install a big pypi package like pytorch (the pytorch's .whl package size is 400+Mb), and one's internet speed is slow (say 400Kb/s). In this situation, we need to wait about 17 minutes to finish downloading. During this time, the user cannot add options to pipenv to display package downloading speed or complete rate.

What I want is something like wget and pip's progress-bar function.

Pull requests are welcome, I agree that would be a great feature

因此,遗憾的是,现在没有一种方法可以拥有与pip相同的功能,或者至少没有一种方法可以模拟pip的^{}选项。请随意点击该线程并订阅该问题,以获得更新,以防其实现

Everyone else on things like tutorials can show the progress bar without additional code. Might it be that in new versions it's not a default setting showing progress bar?

我认为你混淆了pip的下载进度条和pipenv的微调器安装进度条:

$ pipenv install pytest
Installing pytest... 
⠏ Installing pytest...
...
Updated Pipfile.lock (34070a)!
Installing dependencies from Pipfile.lock (34070a)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 —

pipenv install除了安装包之外,还做许多其他事情,例如生成锁文件、更新PIP文件和维护虚拟环境。微调器⠏ Installing pytest...)将所有这些操作考虑在内,通常需要一段时间才能完成。最后的安装栏只是表示“将文件从临时目录移动到虚拟环境”,并没有提供任何信息下载大小和时间。但这两种方法都不能解决你的问题

This is very important for me since I have limited data connection and I need to know in advance the size of the packages I'm downloading.

如果您是从PyPi安装软件包(默认情况下),解决方法是首先转到软件包PyPi页面的“下载文件”部分,并检查下载文件的大小。这是spacy的一个:https://pypi.org/project/spacy/#files

实际上pip install首先要做的是下载那些相同的文件。例如,spacy-3.0.1-*.whl的文件大小约为11~12Mb,这与“spacy-3.0.1-cp39-cp39-win_amd64.whl (11.4 MB)”的大小相匹配

另一种解决方法是向该包的JSON API发出GET请求:https://pypi.org/pypi/spacy/json,并查找releases><version>>size

$ curl https://pypi.org/pypi/spacy/json > spacy.json
$ python3
>>> import json
>>> with open('spacy.json') as f:
...   data = json.load(f)
... 
>>> sizes = [v['size'] for v in data['releases']['3.0.1']]
>>> sizes
[12444769, 12750738, 11605145, 12283655, 12727469, 11606585, 12370380, 12851086, 11760155, 12176093, 12500325, 11395223, 7016311

这将得到相同的11~12Mb估计值。(我没有在脚本中花太多心思,所以它需要大量的工作才能将它变成一个可重用的实用程序,比如pip-check-size <package>之类的东西。它还要求您事先知道版本)

这两种解决方法可能比您现在正在做的更麻烦:

I just do the pip install, check the size, and then immediately abort so that I can go for a pipenv install

相关问题 更多 >