Number of installations statistics for PyPI packages?
Asked Answered
S

10

38

I've got a couple of packages on the Python Package Index (PyPI) now. Is there any way to get hold of statistics as to how many times they have been downloaded (either manually or via easy_install or pip?

Or, alternatively, how many views the main package page has received?

Southwestward answered 29/4, 2012 at 22:7 Comment(0)
C
6

UPDATE 2: it's back! There's now a "Downloads (All Versions)" just after the list of downloads (below the user-supplied docs).

announcement at http://mail.python.org/pipermail/distutils-sig/2013-June/021344.html - it's currently daily counts; weeks and months will be added as they become available. but, curiously, no total.

UPDATE: this no longer works (the info is not displayed) - see http://mail.python.org/pipermail/distutils-sig/2013-May/020855.html (unfortunately this affects the other answer too).

maybe i'm misunderstanding (sorry) but i think this is on the pypi main page for your project!

see updates above for latest details (i've deleted info below that's no longer correct).

Credulous answered 30/4, 2012 at 0:1 Comment(6)
I can't believe I didn't notice that! Doh! Do you happen to know if that includes downloads when it was installed via pip install xxx?Southwestward
i don't know for sure, but i would guess so - that seems to just use http to grab things.Credulous
Maybe I'm just being dumb, but I don't see the "# downloads" column at all when I look at that page...Squinch
see the UPDATE i added 4 hours before your comment?Credulous
Aha! So that's the "this" that no longer works. I don't know whether to feel more or less dumb, now ;)Squinch
I could not found the "Downloads (All Versions)" (7.7.21). I only found: View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery for example: pypi.org/project/numpyDemulcent
I
26

There are at least two packages that help with this: pypstats and vanity. Vanity is very easy to use from the command line:

vanity numpy 

and you'll get a printout to your console.

Interleaf answered 28/3, 2013 at 0:37 Comment(2)
how to send this output to file?Roseboro
vanity does not work anymore.github.com/aclark4life/vanity/issues/66Infeudation
I
19

I have tried the different methods in the other answers. As far as I am concerned, vanity does not work anymore, the reason is here. Pip statistics are not available on pypi.python.org website, the reason is mention in the Python Packaging Guide together with a detailed guide on how you can analyze PyPI download using Google Big Query (summarized below in this answer).

There are 2 methods which are still available.

PyPIstats.org

First method is easier than the second one but seems less reliable as it sometimes returns 429 RATE LIMIT EXCEEDED

  1. Go to pypistats.org;
  2. search the package name;
  3. get the statistics of its download. The following figure is the results of numpy. enter image description here

Google Big Query

Second method is Google Big Query, recommended by PiPy officially.

  1. Go to https://bigquery.cloud.google.com/dataset/the-psf:pypi
  2. Copy the following code into the editor window.
SELECT
  details.installer.name,
  COUNT(*) as download_count,
FROM `the-psf.pypi.downloads*`
WHERE
file.project = 'dvc'
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE('%Y%m%d', DATE('2020-01-04'))
AND FORMAT_DATE('%Y%m%d', DATE('2020-02-04'))
GROUP BY details.installer.name
  1. Click run button, get the results. The following 2 figures show the code and results of numpy.
    code results

Please noter that the second method requires you have a google cloud account, and require you to provide your credict card information, and has limited query times every day. So I personally recommend the first method.

Infeudation answered 19/10, 2020 at 9:12 Comment(3)
Note that pypistats.org seems to offer download statistics from the last six months only.Honeymoon
Note also that Google's BigQuery is available without credit card in some cases.Honeymoon
Clicking bigquery.cloud.google.com/dataset/the-psf:pypi lands me in "Now viewing project 'Valuable-YouTube-Video-Finder' in organisation 'No organisation'".Outrank
L
15

https://pepy.tech/ will show information on the number of downloads and trends over time.

enter image description here

Lupien answered 23/3, 2022 at 15:58 Comment(1)
Finally a site that works, thanks!Selfexistent
A
9

Pip statistics is not available on pypi.python.org website and vanity package does not work as well.

Today you can get pip statistics only through this dataset in BigQuery: https://bigquery.cloud.google.com/dataset/the-psf:pypi

Query example for https://pypi.python.org/pypi/dvc package:

SELECT
  details.system.name,
  COUNT(*) as download_count,
FROM
  TABLE_DATE_RANGE(
    [the-psf:pypi.downloads],
    DATE_ADD(CURRENT_TIMESTAMP(), -31, "day"),
    DATE_ADD(CURRENT_TIMESTAMP(), -1, "day")
  )
WHERE
  file.project = 'dvc'
GROUP BY details.system.name

Please note, some of the download signals are generated by monitoring tools and should not be counted as user's downloads. For example, you should exclude null values from the output:

Row details_system_name download_count   
1   Darwin  1111     
2   null    10000    
3   Windows 222  
4   Linux   3333     
Arose answered 6/5, 2017 at 5:45 Comment(8)
The link you provide doesn't seem to work anymore (unable to find dataset error).Mymya
I've just checked - it seems to work. You need to click "Compose Query" and copy\paste the select statement from the above.Arose
It only works if you are currently a Google BigQuery customer, with an account that has been verified by providing your card details. The service is however free - you are not charged.Mymya
I cant believe how hard it is to obtain such simple statistic, thanks for the answer, this was the only thing that workedAmbala
This answer is so useful that it should be marked as Protected for the communitySalpingotomy
These downloads can be further filtered with details.installer.name to ignore downloads by bandersnatch, which is a mirroring tool.Salpingotomy
The Big Query link seems not work anymore. Waring: "The Classic UI has been decomissioned as of October 1st. Go to Google Cloud Console". After I enter the Google Cloud Console, the code above does not works. Error: "Table-valued function not found: TABLE_DATE_RANGE at [5:3]"Infeudation
Seconding @JingnanJia here. Same observation.lHurdygurdy
C
6

UPDATE 2: it's back! There's now a "Downloads (All Versions)" just after the list of downloads (below the user-supplied docs).

announcement at http://mail.python.org/pipermail/distutils-sig/2013-June/021344.html - it's currently daily counts; weeks and months will be added as they become available. but, curiously, no total.

UPDATE: this no longer works (the info is not displayed) - see http://mail.python.org/pipermail/distutils-sig/2013-May/020855.html (unfortunately this affects the other answer too).

maybe i'm misunderstanding (sorry) but i think this is on the pypi main page for your project!

see updates above for latest details (i've deleted info below that's no longer correct).

Credulous answered 30/4, 2012 at 0:1 Comment(6)
I can't believe I didn't notice that! Doh! Do you happen to know if that includes downloads when it was installed via pip install xxx?Southwestward
i don't know for sure, but i would guess so - that seems to just use http to grab things.Credulous
Maybe I'm just being dumb, but I don't see the "# downloads" column at all when I look at that page...Squinch
see the UPDATE i added 4 hours before your comment?Credulous
Aha! So that's the "this" that no longer works. I don't know whether to feel more or less dumb, now ;)Squinch
I could not found the "Downloads (All Versions)" (7.7.21). I only found: View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery for example: pypi.org/project/numpyDemulcent
A
2

There is a site which I found: https://pypistats.org/packages/py3-pinterest

They track downloads but only for 1 day, 1 week and 1 month. @Dmitry Petrov's answer is better though.

Ambala answered 26/8, 2019 at 11:35 Comment(0)
C
2

You can now use the pypistats website to check your statistics.

For the pytest package: https://pypistats.org/packages/pytest

The figures are coherent with the bigquery's ones. For instance for day 13-04: 501685 downloads without mirror.

Using request :

#standardSQL
SELECT
  COUNT(*) AS num_downloads,
  SUBSTR(_TABLE_SUFFIX, 7, 8) AS `day`
FROM `the-psf.pypi.downloads*`
WHERE file.project = 'pytest'
  AND _TABLE_SUFFIX
    BETWEEN FORMAT_DATE(
      '%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 10 DAY))
    AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
GROUP BY `day`
ORDER BY `day`
Cookhouse answered 14/4, 2020 at 8:23 Comment(0)
P
2

you can use this website for statistics - https://pypistats.org/

if you want to use it in a script you can use the api -

https://pypistats.org/api/packages/{package_name}/recent

Papert answered 21/3, 2022 at 9:34 Comment(4)
I get a 404 when going to pypistats.org/searchLupien
check now @LupienPapert
Great, it works now (without /search)! And the information at pypistats.org/packages/session-info seems similar to what I posted in my answer about pepy.tech so they seem to be pulling from the same source.Lupien
its the same website so make scenes :) @LupienPapert
U
1

If you like to filter the data and check all downloads per installer run:

SELECT
  details.installer.name,
  COUNT(*) as download_count,
FROM `the-psf.pypi.downloads*`
WHERE
file.project = 'dvc'
AND _TABLE_SUFFIX
BETWEEN FORMAT_DATE('%Y%m%d', DATE('2020-01-04'))
AND FORMAT_DATE('%Y%m%d', DATE('2020-02-04'))
GROUP BY details.installer.name

So you should see all the installers for e.g: enter image description here

For more information check useful-queries

Uticas answered 5/2, 2020 at 23:2 Comment(0)
S
1

I came across https://www.piwheels.org which shows how many downloads a PyPi library has had. Just add the library you are checking to the end of this url e.g. numpy

https://www.piwheels.org/project/numpy/

enter image description here

Sibel answered 6/11, 2022 at 0:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.