Search code examples
pythonpipenvpipenv-install

pipenv doesn't show progress bar when installing packages


When I try to install packages with pipenv, the progress bar doesn't show up. This is very important for me since I have a limited data connection and I need to know in advance the size of the packages I'm downloading. This is an example of what I'm getting in pipenv.

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

This is what I get instead when installing packages with normal 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

Is there any way to show the progress bar with pipenv? 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?

I do have some kind of way of telling the size of the package, I just do the pip install, check the size, and then immediately abort so that I can go for a pipenv install.


Solution

  • It is currently not possible with pipenv to show the same download progress bar same as pip. It was requested before, back in July 2018, here: pipenv couldn't display progress bar when it downloads package, and that feature request was closed.

    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.

    Progress bar has been removed in an optimization to batch install which cut the average install time in half.

    So, sadly, there isn't a way now to have the same functionality as pip or at least for a way to emulate pip's --progress-bar option. Feel free to subscribe to that issue to get updates in case it ever gets implemented.

    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?

    I think you are confusing pip's download progress bar and pipenv's spinner and installation progress bar:

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

    pipenv install does many other things aside from installing packages such as generating a lock file, updating your Pipfile, and maintaining your virtual environment. The spinner (⠏ Installing pytest...) factors all those operations in and usually takes a while to complete. The installation bar at the end is just indicating something like "moving files from temp directories to your virtual environment", and doesn't provide any info download size and time. Both of them though doesn't solve your problem.

    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.

    If you are installing packages from PyPi (by default), a workaround is to first go to the "Download files" section of the package's PyPi page, and check the download file sizes. Here's the one for spacy: https://pypi.org/project/spacy/#files.

    What pip install actually first does is to download those same files. For example, the file sizes for spacy-3.0.1-*.whl are around 11~12Mb, which matches what you get for "spacy-3.0.1-cp39-cp39-win_amd64.whl (11.4 MB)".

    Another workaround is to make a GET request to the JSON API for that package: https://pypi.org/pypi/spacy/json, and look for 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
    

    which will get you the same 11~12Mb estimate. (I didn't put a lot of thought into the script, so it needs a lot of work to turn it into a reusable utility like pip-check-size <package> or something. It also requires you to know the version beforehand).

    Both of these workarounds might be more troublesome than what you are already doing now:

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