GithubHelp home page GithubHelp logo

pypinfo's Introduction

pypinfo: View PyPI download statistics with ease.

PyPI version Supported Python versions License Code style: Black

pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

Table of contents

  1. Usage
  2. Installation
  3. Credits

Usage

Click to unfold usage
$ pypinfo
Usage: pypinfo [OPTIONS] [PROJECT] [FIELDS]... COMMAND [ARGS]...
        
    Valid fields are:

    project | version | file | pyversion | percent3 | percent2 | impl | impl-version |
  
    openssl | date | month | year | country | installer | installer-version |
  
    setuptools-version | system | system-release | distro | distro-version | cpu |

    libc | libc-version
    
Options:
    -a, --auth TEXT         Path to Google credentials JSON file.
    --run / --test          --test simply prints the query.
    -j, --json              Print data as JSON, with keys `rows` and `query`.
    -i, --indent INTEGER    JSON indentation level.
    -t, --timeout INTEGER   Milliseconds. Default: 120000 (2 minutes)
    -l, --limit INTEGER        Maximum number of query results. Default: 10
    -d, --days INTEGER         Number of days in the past to include. Default: 30
    -sd, --start-date TEXT  Must be negative or YYYY-MM[-DD]. Default: -31
    -ed, --end-date TEXT    Must be negative or YYYY-MM[-DD]. Default: -1
    -m, --month TEXT        Shortcut for -sd & -ed for a single YYYY-MM month.
    -w, --where TEXT        WHERE conditional. Default: file.project = "project"
    -o, --order TEXT        Field to order by. Default: download_count
    --all                   Show downloads by all installers, not only pip.
    -pc, --percent          Print percentages.
    -md, --markdown         Output as Markdown.
    -v, --verbose           Print debug messages to stderr.
    --version               Show the version and exit.
    -h, --help              Show this message and exit.

pypinfo accepts 0 or more options, followed by exactly 1 project, followed by 0 or more fields. By default only the last 30 days are queried. Let's take a look at some examples!

Tip: If queries are resulting in NoneType errors, increase timeout.

Downloads for a project

$ pypinfo requests
Served from cache: False
Data processed: 2.83 GiB
Data billed: 2.83 GiB
Estimated cost: $0.02

| download_count |
| -------------- |
|    116,353,535 |

All downloads

$ pypinfo ""
Served from cache: False
Data processed: 116.15 GiB
Data billed: 116.15 GiB
Estimated cost: $0.57

| download_count |
| -------------- |
|  8,642,447,168 |

Downloads for a project by Python version

$ pypinfo django pyversion
Served from cache: False
Data processed: 967.33 MiB
Data billed: 968.00 MiB
Estimated cost: $0.01

| python_version | download_count |
| -------------- | -------------- |
| 3.8            |      1,735,967 |
| 3.6            |      1,654,871 |
| 3.7            |      1,326,423 |
| 2.7            |        876,621 |
| 3.9            |        524,570 |
| 3.5            |        258,609 |
| 3.4            |         12,769 |
| 3.10           |          3,050 |
| 3.3            |            225 |
| 2.6            |            158 |
| Total          |      6,393,263 |

All downloads by country code

$ pypinfo "" country
Served from cache: False
Data processed: 150.40 GiB
Data billed: 150.40 GiB
Estimated cost: $0.74

| country | download_count |
| ------- | -------------- |
| US      |  6,614,473,568 |
| IE      |    336,037,059 |
| IN      |    192,914,402 |
| DE      |    186,968,946 |
| NL      |    182,691,755 |
| None    |    141,753,357 |
| BE      |    111,234,463 |
| GB      |    109,539,219 |
| SG      |    106,375,274 |
| FR      |     86,036,896 |
| Total   |  8,068,024,939 |

Downloads for a project by system and distribution

$ pypinfo cryptography system distro
Served from cache: False
Data processed: 2.52 GiB
Data billed: 2.52 GiB
Estimated cost: $0.02

| system_name | distro_name                     | download_count |
| ----------- | ------------------------------- | -------------- |
| Linux       | Ubuntu                          |     19,524,538 |
| Linux       | Debian GNU/Linux                |     11,662,104 |
| Linux       | Alpine Linux                    |      3,105,553 |
| Linux       | Amazon Linux AMI                |      2,427,975 |
| Linux       | Amazon Linux                    |      2,374,869 |
| Linux       | CentOS Linux                    |      1,955,181 |
| Windows     | None                            |      1,522,069 |
| Linux       | CentOS                          |        568,370 |
| Darwin      | macOS                           |        489,859 |
| Linux       | Red Hat Enterprise Linux Server |        296,858 |
| Total       |                                 |     43,927,376 |

Most popular projects in the past year

$ pypinfo --days 365 "" project
Served from cache: False
Data processed: 1.69 TiB
Data billed: 1.69 TiB
Estimated cost: $8.45

| project         | download_count |
| --------------- | -------------- |
| urllib3         |  1,382,528,406 |
| six             |  1,172,798,441 |
| botocore        |  1,053,169,690 |
| requests        |    995,387,353 |
| setuptools      |    992,794,567 |
| certifi         |    948,518,394 |
| python-dateutil |    934,709,454 |
| idna            |    929,781,443 |
| s3transfer      |    877,565,186 |
| chardet         |    854,744,674 |
| Total           | 10,141,997,608 |

Downloads between two YYYY-MM-DD dates

$ pypinfo --start-date 2018-04-01 --end-date 2018-04-30 setuptools
Served from cache: False
Data processed: 571.37 MiB
Data billed: 572.00 MiB
Estimated cost: $0.01

| download_count |
| -------------- |
|      8,972,826 |

Downloads between two YYYY-MM dates

  • A yyyy-mm --start-date defaults to the first day of the month
  • A yyyy-mm --end-date defaults to the last day of the month
$ pypinfo --start-date 2018-04 --end-date 2018-04 setuptools
Served from cache: False
Data processed: 571.37 MiB
Data billed: 572.00 MiB
Estimated cost: $0.01

| download_count |
| -------------- |
|      8,972,826 |

Downloads for a single YYYY-MM month

$ pypinfo --month 2018-04 setuptools
Served from cache: False
Data processed: 571.37 MiB
Data billed: 572.00 MiB
Estimated cost: $0.01

| download_count |
| -------------- |
|      8,972,826 |

Percentage of Python 3 downloads of the top 100 projects in the past year

Let's use --test to only see the query instead of sending it.

$ pypinfo --test --days 365 --limit 100 "" project percent3
SELECT
    file.project as project,
    ROUND(100 * SUM(CASE WHEN REGEXP_EXTRACT(details.python, r"^([^\.]+)") = "3" THEN 1 ELSE 0 END) / COUNT(*), 1) as percent_3,
    COUNT(*) as download_count,
FROM `bigquery-public-data.pypi.file_downloads`
WHERE timestamp BETWEEN TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL -366 DAY) AND TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL -1 DAY)
    AND details.installer.name = "pip"
GROUP BY
    project
ORDER BY
    download_count DESC
LIMIT 100

Downloads for a given version

pypinfo supports PEP 440 version matching.

We can use it to query stats on a given major version.

$ pypinfo -pc 'pip==21.*' pyversion version
Served from cache: False
Data processed: 34.45 MiB
Data billed: 35.00 MiB
Estimated cost: $0.01

| python_version | version | percent | download_count |
| -------------- | ------- | ------- | -------------- |
| 3.6            | 21.3.1  |  78.74% |         10,430 |
| 3.8            | 21.3.1  |   7.81% |          1,034 |
| 3.7            | 21.2.1  |   3.59% |            476 |
| 3.7            | 21.3.1  |   2.60% |            345 |
| 3.7            | 21.0.1  |   2.25% |            298 |
| 3.8            | 21.0.1  |   1.58% |            209 |
| 3.8            | 21.2.1  |   1.42% |            188 |
| 3.7            | 21.1.2  |   0.81% |            107 |
| 3.9            | 21.3.1  |   0.69% |             92 |
| 3.8            | 21.1.1  |   0.51% |             67 |
| Total          |         |         |         13,246 |

We can also use it to query stats on an exact version:

$ pypinfo -pc 'numpy==1.23rc3' pyversion version
Served from cache: False
Data processed: 34.01 MiB
Data billed: 35.00 MiB
Estimated cost: $0.01

| python_version | version   | percent | download_count |
| -------------- | --------- | ------- | -------------- |
| 3.9            | 1.23.0rc3 |  63.33% |             38 |
| 3.8            | 1.23.0rc3 |  28.33% |             17 |
| 3.10           | 1.23.0rc3 |   8.33% |              5 |
| Total          |           |         |             60 |

Check how many downloads came from continuous integration servers:

pypinfo --percent --days 5 pillow ci
Served from cache: False
Data processed: 384.22 MiB
Data billed: 385.00 MiB
Estimated cost: $0.01

| ci    | percent | download_count |
| ----- | ------- | -------------- |
| None  |  79.37% |     11,963,127 |
| True  |  20.63% |      3,109,931 |
| Total |         |     15,073,058 |

Installation

Click to unfold installation

pypinfo is distributed on PyPI as a universal wheel and is available on Linux/macOS and Windows and supports Python 3.7+.

This is relatively painless, I swear.

Create project

  1. Go to https://bigquery.cloud.google.com.

  2. Sign up if you haven't already. The first TB of queried data each month is free. Each additional TB is $5.

  3. Sign in on your account if you are not already;

  4. Go to https://console.developers.google.com/cloud-resource-manager and click CREATE PROJECT if you don't already have one:

create

  1. This takes you to https://console.developers.google.com/projectcreate. Fill out the form and click CREATE. Any name is fine, but I recommend you choose something to do with PyPI like pypinfo. This way you know what the project is designated for:

click

  1. A while after creation, at the left-top corner, select the project name of your choice on dropdown component AND at the left-top corner "Navigation Menu", select option "Cloud Overview > Dashboard":

show

Enable BigQuery API

  1. Click on top-left button "Navigation Menu" and click on option "API and services > Library":

api_library

  1. Perform a search with keywords "big query api" on available text field:

big_query_api_search

  1. Enable Big Query API by button "Enable" press:

big_query_api

  1. After enabling, click CREATE CREDENTIALS:

credentials

Note: You will be requested to go back to Big Query panel. In this case, click on top-left button "Navigation Menu", option "API and services > Enabled APIs and services" and on consequent page, on item "Big Query API":

enabled_credentials

  1. On the page after clicking the "CREATE CREDENTIALS" button, choose "BigQuery API", "Application Data" and "No, I'm not using them":

credentials_page_1

  1. Fill account details and press button "Create and Continue":

credentials_page_2

  1. Select role "BigQuery User" (option path "BigQuery > Big Query User"), press button "Done":

credentials_page_3

  1. On Big Query API panel (See Note on item 10), click on tab "CREDENTIALS". On section "Service accounts", click on created credentials on items 11, 12 and 13.

create_service_credential_key

  1. On page from credential click, click on tab "KEYS". On dropdown menu "ADD KEY", click on option "Create new key":

create_credential_key

  1. On appearing box, click on option "JSON" and press button "CREATE": This will start the download of credentials on a JSON file with name pattern {name}-{credentials_hash}.json:

create_private_key

Installation and authentication

  1. Run python -m pip install pypinfo in the terminal.
  2. pypinfo --auth path/to/your_credentials.json, or set an environment variable GOOGLE_APPLICATION_CREDENTIALS that points to the file.

Credits

pypinfo's People

Contributors

brunolnetto avatar bskinn avatar enarroied avatar hugovk avatar jdufresne avatar julienpalard avatar jwilk avatar mayeut avatar ofek avatar rahiel avatar tswast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pypinfo's Issues

feature request - trend support

Hello,

It would be great to be able to tell project tendencies. E.g are my monthly usage going up or down? This is already possible with playing around the start and end date, but what about providing a builtin way of this, that does not require shell scripting it?

Automatically insert argument to "--order" into the "fields" list, if it's not already present

If pypinfo is called with an --order argument, but the corresponding field is not present in the list of fields provided after the desired package name, the BigQuery API complains:

>pypinfo -o date numpy
Traceback (most recent call last):
...
google.api.core.exceptions.BadRequest: 400 POST https://www.googleapis.com/bigquery/v2/projects/pypi
nfo-btskinn/queries: SELECT clause has mix of aggregations 'download_count' and fields 'download_dat
e' without GROUP BY clause

Whereas everything's fine when the field is explicitly passed:

>pypinfo -o date numpy date
download_date download_count
------------- --------------
2017-09-28    136028
2017-09-27    88843
2017-09-26    94603
2017-09-25    93221
2017-09-24    61966
2017-09-23    64148
2017-09-22    95677
2017-09-21    97871
2017-09-20    93427
2017-09-19    87520
2017-09-18    93313
2017-09-17    62543
2017-09-16    63271
2017-09-15    80160
2017-09-14    92697
2017-09-13    90869
2017-09-12    79222
2017-09-11    65286
2017-09-10    57141
2017-09-09    47484

Perhaps a check should be added for the presence of the --order argument in the fields list, with the sort field added to parsed_fields if it's not there? (Probably right after this would be good.)

ModuleNotFoundError: No module named 'google.api_core'

FYI, this is a Google problem, I've reported it here: googleapis/google-cloud-python#4395.

Short version:

[hugo:/tmp] 5s % python3
Python 3.6.0 (default, Mar  4 2017, 12:32:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from google.cloud import bigquery
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/bigquery/__init__.py", line 34, in <module>
    from google.cloud.bigquery._helpers import DEFAULT_RETRY
  File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/bigquery/_helpers.py", line 23, in <module>
    from google.api_core import retry
ModuleNotFoundError: No module named 'google.api_core'
>>>

Longer version:

After having done a recent pip3 install -U pypinfo:

[hugo:/tmp] % python3 --version
Python 3.6.0

[hugo:/tmp] 1 % pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

[hugo:/tmp] 9s % pip3 install -U pypinfo
Requirement already up-to-date: pypinfo in /usr/local/lib/python3.6/site-packages
Requirement already up-to-date: click in /usr/local/lib/python3.6/site-packages/click-6.7-py3.6.egg (from pypinfo)
Requirement already up-to-date: tinydb in /usr/local/lib/python3.6/site-packages (from pypinfo)
Requirement already up-to-date: appdirs in /usr/local/lib/python3.6/site-packages/appdirs-1.4.3-py3.6.egg (from pypinfo)
Requirement already up-to-date: tinyrecord in /usr/local/lib/python3.6/site-packages/tinyrecord-0.1.3-py3.6.egg (from pypinfo)
Requirement already up-to-date: google-cloud-bigquery>=0.28.0 in /usr/local/lib/python3.6/site-packages (from pypinfo)
Requirement already up-to-date: google-api-core<0.2.0dev,>=0.1.1 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: requests>=2.18.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: google-cloud-core<0.29dev,>=0.28.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: google-auth>=1.0.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: google-resumable-media>=0.2.1 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: protobuf>=3.0.0 in /usr/local/lib/python3.6/site-packages/protobuf-3.4.0-py3.6.egg (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: googleapis-common-protos<2.0dev,>=1.5.3 in /usr/local/lib/python3.6/site-packages/googleapis_common_protos-1.5.3-py3.6.egg (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: setuptools>=34.0.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: idna<2.7,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: rsa>=3.1.4 in /usr/local/lib/python3.6/site-packages/rsa-3.4.2-py3.6.egg (from google-auth>=1.0.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: cachetools>=2.0.0 in /usr/local/lib/python3.6/site-packages/cachetools-2.0.1-py3.6.egg (from google-auth>=1.0.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: pyasn1-modules>=0.0.5 in /usr/local/lib/python3.6/site-packages/pyasn1_modules-0.1.5-py3.6.egg (from google-auth>=1.0.0->google-cloud-bigquery>=0.28.0->pypinfo)
Requirement already up-to-date: pyasn1>=0.1.7 in /usr/local/lib/python3.6/site-packages/pyasn1-0.3.7-py3.6.egg (from google-auth>=1.0.0->google-cloud-bigquery>=0.28.0->pypinfo)

[hugo:/tmp] 2s % pip3 freeze | grep pypinfo
pypinfo==7.0.0

[hugo:/tmp] % pip3 freeze | grep google-cloud-bigquery
google-cloud-bigquery==0.28.0

[hugo:/tmp] % pip3 freeze | grep google
google-api-core==0.1.1
google-auth==1.2.1
google-cloud-bigquery==0.28.0
google-cloud-core==0.28.0
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3

[hugo:/tmp] % pypinfo pypinfo
Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 7, in <module>
    from pypinfo.cli import pypinfo
  File "/usr/local/lib/python3.6/site-packages/pypinfo/cli.py", line 3, in <module>
    from pypinfo.core import (
  File "/usr/local/lib/python3.6/site-packages/pypinfo/core.py", line 5, in <module>
    from google.cloud.bigquery import Client
  File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/bigquery/__init__.py", line 34, in <module>
    from google.cloud.bigquery._helpers import DEFAULT_RETRY
  File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/bigquery/_helpers.py", line 23, in <module>
    from google.api_core import retry
ModuleNotFoundError: No module named 'google.api_core'

`SystemError: Credentials could not be found.` on a public data access comman run

Hi fellows,

I just installed pypinfo and ran the command pypinfo requests as you suggested. The following error popped out:

Traceback (most recent call last):
  File "/home/brunolnetto/.local/bin/pypinfo", line 8, in <module>
    sys.exit(pypinfo())
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/click/core.py", line 1637, in invoke
    super().invoke(ctx)
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/pypinfo/cli.py", line 168, in pypinfo
    with create_client(get_credentials()) as client:
  File "/home/brunolnetto/.local/lib/python3.8/site-packages/pypinfo/core.py", line 55, in create_client
    raise SystemError('Credentials could not be found.')
SystemError: Credentials could not be found.

I did not expect to register any credentials. I suspect, this library is helpful for only PyPI staff team (command run pypinfo output, among others, -a, --auth TEXT Path to Google credentials JSON file.), which means the credential corresponds to the respective BigQuery API key. Nevertheless, I am glad to make this argument, since the documentation claims, the library, and data have public access.

Remark: You lost the opportunity to name it pynfo :-P

Increase Tests Coverage

Increase test coverage writing test scripts for the rest of the python files missing.
I will be adding tests scripts for

  • pypinfo/cli.py
  • pypinfo/db.py
  • pypinfo/fields.py

--json option prints more than JSON

I was hoping to use the output of the script to spit out JSON I can bring in later. I invoke this way:

pypinfo --json --order download_date --start-date -365 --days 365 --limit 365 foo     date > ~/foo.json

File /foo.json doesn't contain valid JSON because there's some stuff before it:

Served from cache: False
Data processed: 151.63 GiB
Data billed: 151.63 GiB
Estimated cost: $0.75

[
  {
    "download_count": 24,
    "download_date": "2018-02-04"
  },
  {
    "download_count": 49,
    "download_date": "2018-02-03"
  },
  {
...

Workaround is to strip everything before the first [. Something like:

json = read_data[read_data.find('['):]

Allow YYYY-MM-DD dates in --start-date and --end-date

It'd be handy to be able to use YYYY-MM-DD dates as the start and end date. For example:

$ pypinfo --start-date 2018-01-01 --end-date 2018-01-31 pillow pyversion

Rather than having to work it out:

$ pypinfo --start-date -43 --end-date -14 pillow pyversion

It wouldn't necessarily have to reuse --start-date and --end-date, but that's probably clearest and easiest (if not negative integer, it's a date).

What do you think?

Extra package (requests[security]) won't worked.

$ pypinfo --days 2 "requests[security]" pyversion
Served from cache: False
Data processed: 9.43 GiB
Data billed: 9.43 GiB
Estimated cost: $0.05

Traceback (most recent call last):
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4-konlpy/bin/pypinfo", line 10, in <module>
    sys.exit(pypinfo())
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/pypinfo/cli.py", line 195, in pypinfo
    click.echo(tabulate(rows, markdown))
  File "/Users/minhoryang/.anyenv/envs/pyenv/versions/3.7.4/envs/3.7.4-konlpy/lib/python3.7/site-packages/pypinfo/core.py", line 238, in tabulate
    for i in range(len(rows[0])):
IndexError: list index out of range

Enforce "python 3 only" in setup.py

It is currently possible to install this package on Python 2 (via pip). It breaks when pypinfo is invoked from cmdline thought. I think setup.py should detect the Python version at runtime and prevent installing.

~/svn/smartfile/tp/python$ pypinfo
Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3142, in <module>
    @_call_aside
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3126, in _call_aside
    f(*args, **kwargs)
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3155, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 666, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 679, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 872, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (pyasn1 0.2.2 (/home/giampaolo/.local/lib/python2.7/site-packages), Requirement.parse('pyasn1<0.4.0,>=0.3.4'), set(['pyasn1-modules']))
~/svn/smartfile/tp/python$ pypinfo
Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 11, in <module>
    load_entry_point('pypinfo==5.0.0', 'console_scripts', 'pypinfo')()
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 570, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
    return ep.load()
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2409, in load
    return self.resolve()
  File "/home/giampaolo/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2415, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/giampaolo/svn/pypinfo/pypinfo/cli.py", line 3, in <module>
    from pypinfo.core import build_query, create_client, format_json, parse_query_result, tabulate, add_percentages
  File "/home/giampaolo/svn/pypinfo/pypinfo/core.py", line 148
    headers, *data = rows

Installation failed: AttributeError: '_NamespacePath' object has no attribute 'sort'

When I try to install pypinfo, this happens:

jakob@Pluto:~$ sudo pip3 install pypinfo
[sudo] Passwort für jakob: 
WARNING: The directory '/home/jakob/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/jakob/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pypinfo
  Downloading https://files.pythonhosted.org/packages/19/f6/b62ba0fedb6638f20a453168d39c82878d01a06cb6829faebf1f8786f8a1/pypinfo-15.0.0-py2.py3-none-any.whl
Collecting google-cloud-bigquery>=0.29.0 (from pypinfo)
  Downloading https://files.pythonhosted.org/packages/89/1d/145b045a6bf8b3d1216f68b4ee55fe4932c24c2ee86c0dab971071dae6c5/google_cloud_bigquery-1.20.0-py2.py3-none-any.whl (154kB)
     |████████████████████████████████| 163kB 1.1MB/s 
Collecting appdirs (from pypinfo)
  Downloading https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
Requirement already satisfied: click in /usr/lib/python3/dist-packages (from pypinfo) (6.2)
Collecting binary (from pypinfo)
  Downloading https://files.pythonhosted.org/packages/b4/ba/37de520e4870635793164a3d6861d98357d4e43aa6ce244327183ccaa3cb/binary-1.0.0-py2.py3-none-any.whl
Collecting tinyrecord (from pypinfo)
  Downloading https://files.pythonhosted.org/packages/62/5e/b69f5111206c85e7e4ed1824e8dd1fa216c6045ad812d45defc012557702/tinyrecord-0.1.5.tar.gz
Collecting tinydb (from pypinfo)
  Downloading https://files.pythonhosted.org/packages/dc/90/ced9f2a57513eb75dce70760e55967ceedbf2dc158b6a66f1bf87ac8fab0/tinydb-3.14.1-py2.py3-none-any.whl
Collecting google-cloud-core<2.0dev,>=1.0.3 (from google-cloud-bigquery>=0.29.0->pypinfo)
  Downloading https://files.pythonhosted.org/packages/ee/f0/084f598629db8e6ec3627688723875cdb03637acb6d86999bb105a71df64/google_cloud_core-1.0.3-py2.py3-none-any.whl
Collecting protobuf>=3.6.0 (from google-cloud-bigquery>=0.29.0->pypinfo)
  Downloading https://files.pythonhosted.org/packages/27/1c/ccf7810d5d02bdaafc223af032e8ac7f5ad6d23c5d0a44682a5a85fdda25/protobuf-3.10.0-cp35-cp35m-manylinux1_x86_64.whl (1.3MB)
     |████████████████████████████████| 1.3MB 531kB/s 
Collecting google-resumable-media>=0.3.1 (from google-cloud-bigquery>=0.29.0->pypinfo)
  Downloading https://files.pythonhosted.org/packages/96/d7/b29a41b01b854480891dfc408211ffb0cc7a2a3d5f15a3b6740ec18c845b/google_resumable_media-0.4.1-py2.py3-none-any.whl
Collecting google-api-core<2.0.0dev,>=1.14.0 (from google-cloud-core<2.0dev,>=1.0.3->google-cloud-bigquery>=0.29.0->pypinfo)
  Downloading https://files.pythonhosted.org/packages/29/3a/c528ef37f48d6ffba16f0f3c0426456ba21e0dd32be9c61a2ade93e07faa/google_api_core-1.14.3-py2.py3-none-any.whl (68kB)
     |████████████████████████████████| 71kB 1.0MB/s 
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from protobuf>=3.6.0->google-cloud-bigquery>=0.29.0->pypinfo) (20.7.0)
Requirement already satisfied: six>=1.9 in ./.local/lib/python3.5/site-packages (from protobuf>=3.6.0->google-cloud-bigquery>=0.29.0->pypinfo) (1.12.0)
Requirement already satisfied: requests<3.0.0dev,>=2.18.0 in /usr/local/lib/python3.5/dist-packages (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.3->google-cloud-bigquery>=0.29.0->pypinfo) (2.22.0)
Collecting googleapis-common-protos<2.0dev,>=1.6.0 (from google-api-core<2.0.0dev,>=1.14.0->google-cloud-core<2.0dev,>=1.0.3->google-cloud-bigquery>=0.29.0->pypinfo)
  Downloading https://files.pythonhosted.org/packages/eb/ee/e59e74ecac678a14d6abefb9054f0bbcb318a6452a30df3776f133886d7d/googleapis-common-protos-1.6.0.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 11, in <module>
        from setuptools.extern.six.moves import filterfalse, map
      File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
        @_call_aside
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
        f(*args, **kwargs)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
        add_activation_listener(lambda dist: dist.activate())
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 956, in subscribe
        callback(dist)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in <lambda>
        add_activation_listener(lambda dist: dist.activate())
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2515, in activate
        declare_namespace(pkg)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
        _handle_ns(packageName, path_item)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: '_NamespacePath' object has no attribute 'sort'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-33ap899x/googleapis-common-protos/
WARNING: You are using pip version 19.1.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
jakob@Pluto:~$ 

breakdown by installer now shows only pip

Hi There,

Compared to the results returned in Aug 2018, my trials today with pypinfo returns download count for pip only. Is this expected or a bug? What happened to other installers? how can I get a count that's as comprehensive as possible? Thanks.

Also, what's the easiest/fastest way to obtain all-time download count for a particular package (entire life-time)?

download counts for neuropredict package with the command
pypinfo -sd -400 neuropredict installer :

Aug 2018

| installer_name | download_count |
| -------------- | -------------- |
| bandersnatch   |         14,182 |
| requests       |            262 |
| Browser        |            248 |
| pip            |             87 |
| None           |             66 |
| z3c.pypimirror |             34 |
| Artifactory    |             23 |
| pep381client   |             20 |
| devpi          |              3 |

Jan 2019

| installer_name | download_count |
| -------------- | -------------- |
| pip            |            241 |

Disclose BigTable Costs in Readme

After spending a bunch of time setting up the GCP account, and looking at usage, it seems to be very expensive.

After the free tier is consumed and the 90day $300 credit expires, BigQuery costs $5 per TB of data queried. Querying the simple_requests table which is 49.77 TB would cost $250 per query.

A query of the distribution_metadata table (18.8GB) would cost $0.094 per query. Again very expensive..

Placing the data in AWS S3 using S3 Select cost about the same, still very expensive.

I think this should be fully disclosed in the readme file

ImportError: cannot import name 'opentype'

From a fresh install

$ pypinfo --help

Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 7, in <module>
    from pypinfo.cli import pypinfo
  File "/usr/local/lib/python3.5/dist-packages/pypinfo/cli.py", line 3, in <module>
    from pypinfo.core import (
  File "/usr/local/lib/python3.5/dist-packages/pypinfo/core.py", line 5, in <module>
    from google.cloud.bigquery import Client
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
    from google.cloud.bigquery.client import Client
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/bigquery/client.py", line 36, in <module>
    from google.cloud.client import ClientWithProject
  File "/usr/local/lib/python3.5/dist-packages/google/cloud/client.py", line 27, in <module>
    from google.oauth2 import service_account
  File "/usr/local/lib/python3.5/dist-packages/google/oauth2/service_account.py", line 77, in <module>
    from google.auth import _service_account_info
  File "/usr/local/lib/python3.5/dist-packages/google/auth/_service_account_info.py", line 22, in <module>
    from google.auth import crypt
  File "/usr/local/lib/python3.5/dist-packages/google/auth/crypt/__init__.py", line 39, in <module>
    from google.auth.crypt import rsa
  File "/usr/local/lib/python3.5/dist-packages/google/auth/crypt/rsa.py", line 17, in <module>
    from google.auth.crypt import _python_rsa
  File "/usr/local/lib/python3.5/dist-packages/google/auth/crypt/_python_rsa.py", line 29, in <module>
    from pyasn1_modules.rfc2459 import Certificate
  File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <module>
    from pyasn1.type import opentype
ImportError: cannot import name 'opentype'

Web api availability

Is there a web api available?

So, that I can download or query the json directly from there.

Note: I followed all the steps given in the doc to create a bigquery project. I can use the tool on command line and I know that I can use --json flag to get the json response.

Incorrect documentation for projects argument

Running verison 19 on W10 with powershell, I cannot perform queries on all projects.

A command like pypinfo --days 365 "" project will query the package project and return

| download_count |
| -------------- |
|          4,807 |

similar results with any query that uses "" as the project name.

YYYY-MM-DD dates issue in --start-date and --end-date

I noticed that the date issue has been fixed in #49. However, I still can't use dates. Please see below. Could you please let me know how to use the start and end dates properly? Thanks!

$ pypinfo --start-date 2018-04-01 --end-date 2018-04-30 setuptools
Traceback (most recent call last):
  File "/anaconda3/bin/pypinfo", line 11, in <module>
    sys.exit(pypinfo())
  File "/anaconda3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/anaconda3/lib/python3.6/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/anaconda3/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/anaconda3/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/pypinfo/cli.py", line 100, in pypinfo
    end_date=end_date, where=where, order=order_name, pip=pip
  File "/anaconda3/lib/python3.6/site-packages/pypinfo/core.py", line 56, in build_query
    if int(start_date) > 0 or int(end_date) > 0:
ValueError: invalid literal for int() with base 10: '2018-04-01'

--where ignores project

These match because --where 'file.project = "project"' gets silently overridden:

$ pypinfo --days 1095 --limit 36 --order download_month --where 'details.python = "1.17"' '' month
Served from cache: False
Data processed: 186.48 GiB
Data billed: 186.48 GiB
Estimated cost: $0.92

| download_month | download_count |
| -------------- | -------------- |
| 2018-03        |         18,667 |
| 2018-02        |         67,154 |
| 2018-01        |      1,898,377 |
| 2017-12        |         70,865 |
| 2017-11        |         64,577 |
| 2017-10        |         66,968 |
| 2017-09        |         63,809 |
| 2017-08        |         93,022 |
| 2017-07        |        628,639 |
| 2017-06        |        200,335 |
| 2017-05        |        148,618 |
| 2017-04        |         50,842 |
| 2017-03        |         53,755 |
| 2017-02        |         47,414 |
| 2017-01        |         50,651 |
| 2016-12        |         53,138 |
| 2016-11        |        129,537 |
| 2016-10        |        477,819 |
| 2016-09        |      1,013,797 |
| 2016-08        |        116,291 |
| 2016-07        |         81,521 |
| 2016-06        |         59,695 |
| 2016-05        |        151,872 |
| 2016-03        |          4,618 |
| 2016-02        |        226,267 |
| 2016-01        |        184,133 |
$ pypinfo --days 1095 --limit 36 --order download_month --where 'details.python = "1.17"' certifi month
Served from cache: True
Data processed: 0.00 B
Data billed: 0.00 B
Estimated cost: $0.00

| download_month | download_count |
| -------------- | -------------- |
| 2018-03        |         18,667 |
| 2018-02        |         67,154 |
| 2018-01        |      1,898,377 |
| 2017-12        |         70,865 |
| 2017-11        |         64,577 |
| 2017-10        |         66,968 |
| 2017-09        |         63,809 |
| 2017-08        |         93,022 |
| 2017-07        |        628,639 |
| 2017-06        |        200,335 |
| 2017-05        |        148,618 |
| 2017-04        |         50,842 |
| 2017-03        |         53,755 |
| 2017-02        |         47,414 |
| 2017-01        |         50,651 |
| 2016-12        |         53,138 |
| 2016-11        |        129,537 |
| 2016-10        |        477,819 |
| 2016-09        |      1,013,797 |
| 2016-08        |        116,291 |
| 2016-07        |         81,521 |
| 2016-06        |         59,695 |
| 2016-05        |        151,872 |
| 2016-03        |          4,618 |
| 2016-02        |        226,267 |
| 2016-01        |        184,133 |

This isn't a huge deal other than there isn't really a reason to even accept project in these cases.

Maybe it'd be better to tell people to run --where 'file.project = "project"' themselves or to work in an AND on custom --wheres:

$ pypinfo --days 1095 --limit 36 --order download_month --where 'details.python = "1.17" AND file.project = "certifi"' '' month
Served from cache: False
Data processed: 331.50 GiB
Data billed: 331.50 GiB
Estimated cost: $1.62

| download_month | download_count |
| -------------- | -------------- |
| 2018-03        |             70 |
| 2018-02        |             68 |
| 2018-01        |            155 |
| 2017-12        |             93 |
| 2017-11        |            116 |
| 2017-10        |             90 |
| 2017-09        |             95 |
| 2017-08        |             86 |
| 2017-07        |            112 |
| 2017-06        |             83 |
| 2017-05        |             69 |
| 2017-04        |             29 |
| 2017-03        |             12 |
| 2017-02        |             10 |
| 2017-01        |             13 |
| 2016-12        |              8 |
| 2016-11        |              8 |
| 2016-10        |             15 |
| 2016-09        |             55 |
| 2016-08        |             19 |
| 2016-07        |              3 |
| 2016-06        |             14 |
| 2016-05        |              3 |
| 2016-03        |              4 |
| 2016-02        |             13 |
| 2016-01        |              7 |

--order is affected by the same issue.

No matching signature for function DATE_ADD for argument types: TIMESTAMP, INTERVAL INT64 DATE_TIME_PART

Hi,

After installation following instructions given in the README.md, I tried a simplest call:

pypinfo requests

Unfortunately getting following exception:

...
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/pypinfo/cli.py", line 166, in pypinfo
    query_rows = query_job.result(timeout=timeout // 1000)
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/google/cloud/bigquery/job/query.py", line 1160, in result
    super(QueryJob, self).result(retry=retry, timeout=timeout)
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/google/cloud/bigquery/job/base.py", line 631, in result
    return super(_AsyncJob, self).result(timeout=timeout, **kwargs)
  File "/Users/christianr/.venv/sett/lib/python3.9/site-packages/google/api_core/future/polling.py", line 134, in result
    raise self._exception
google.api_core.exceptions.BadRequest: 400 No matching signature for function DATE_ADD for argument types: TIMESTAMP, INTERVAL INT64 DATE_TIME_PART. Supported signature: DATE_ADD(DATE, INTERVAL INT64 DATE_TIME_PART) at [5:25]

(job ID: 947e6084-e5e6-4bb5-ae12-bb8faad8ec0b)

                                                 -----Query Job SQL Follows-----

    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |
   1:SELECT
   2:  FORMAT_TIMESTAMP("%Y", timestamp) as download_year,
   3:  COUNT(*) as download_count,
   4:FROM `the-psf.pypi.file_downloads`
   5:WHERE timestamp BETWEEN DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL -1826 DAY) AND DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL -1 DAY)
   6:  AND file.project = "blist"
   7:  AND details.installer.name = "pip"
   8:GROUP BY
   9:  download_year
  10:ORDER BY
  11:  download_count DESC
  12:LIMIT 10
    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |

Using the SQL query in the BigQuery SQL workspace pops up the same error message if I use the public PyPI download statistics dataset.

My environment:

pypinfo, version 18.0.0
Python 3.9.1

wrong installation hints

This is relatively painless, I swear.

Well...

During creation, choose BigQuery User as role.

First off, which of

  • API key
  • OAuth client ID
  • Service accout key

do I choose? I suppose Service account key since this is the only one that takes me to another screen with role in it. There's no such rule as BigQuery User however.

How to check current BigQuery usage

Whilst making #29 I got this:

    raise exceptions.from_http_response(response)
google.api_core.exceptions.Forbidden: 403 GET https://www.googleapis.com/bigquery/v2/projects/pypinfo-hugovk/queries/<snip>?maxResults=0&timeoutMs=10000: Quota exceeded: Your project exceeded quota for free query bytes scanned. For more information, see https://cloud.google.com/bigquery/troubleshooting-errors

I can't find how much of my free monthly TB I've used up on the Google console.

After some digging in the console I found this:

image

https://console.cloud.google.com/home/activity?project=pypinfo-hugovk&authuser=1

Linking to this:

image

https://console.cloud.google.com/iam-admin/quotas?project=pypinfo-hugovk&authuser=1

Which isn't very informative -- all zeroes and dashes!

I get the error after doing several pypinfo --percent --pip pypinfo pyversion, but pypinfo --percent --pip -d 1 pypinfo is still fine.

Any idea what "QUERY-MBYTES-FOR-UNBILLED-PROJECTS-per-project" really means?

And where to check the monthly 1TB quota?

Thanks!

Inconsistent results

Any known reason why or how the total download count could decrease between calls ? I've had my download count drop more than once on different pypinfo calls a few days apart from each other.

RuntimeWarning for numpy

Hi,

I get this error even when running no command args:

$ pypinfo
/usr/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
/usr/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
Usage: pypinfo [OPTIONS] [PROJECT] [FIELDS]... COMMAND [ARGS]...

  Valid fields are:

  project | version | file | pyversion | percent3 | percent2 | impl | impl-version |

  openssl | date | month | year | country | installer | installer-version |

  setuptools-version | system | system-release | distro | distro-version | cpu

Options:
  -a, --auth TEXT         Path to Google credentials JSON file.
  --run / --test          --test simply prints the query.
  -j, --json              Print data as JSON, with keys `rows` and `query`.
  -i, --indent INTEGER    JSON indentation level.
  -t, --timeout INTEGER   Milliseconds. Default: 120000 (2 minutes)
  -l, --limit TEXT        Maximum number of query results. Default: 10
  -d, --days TEXT         Number of days in the past to include. Default: 30
  -sd, --start-date TEXT  Must be negative. Default: -31
  -ed, --end-date TEXT    Must be negative. Default: -1
  -w, --where TEXT        WHERE conditional. Default: file.project = "project"
  -o, --order TEXT        Field to order by. Default: download_count
  -p, --pip               Only show installs by pip.
  -pc, --percent          Print percentages.
  -md, --markdown         Output as Markdown.
  --version               Show the version and exit.
  --help                  Show this message and exit.

'Client' object has no attribute 'run_sync_query'

First of all, thank you so much for building this package.
I'm excited to start using it, but it has been crashing for me on every query run:

coding@Aarons-MBP pypinfo (master)$ pypinfo django date
Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 11, in <module>
    load_entry_point('pypinfo==5.0.0', 'console_scripts', 'pypinfo')()
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pypinfo/cli.py", line 89, in pypinfo
    query = client.run_sync_query(built_query)
AttributeError: 'Client' object has no attribute 'run_sync_query'

I tried python2, updating gcloud, etc. to no avail.

error if 0 downloads

The following works:

pypinfo estimationpy
download_count
0

But then this fails:

pypinfo estimationpy pyversion

Traceback (most recent call last):
  File "c:\users\matthis.thorade\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\matthis.thorade\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\matthis.thorade\Anaconda3\Scripts\pypinfo.exe\__main__.py", line 9, in <module>
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\click\core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\pypinfo\cli.py", line 184, in pypinfo
    click.echo(tabulate(rows, markdown))
  File "c:\users\matthis.thorade\anaconda3\lib\site-packages\pypinfo\core.py", line 210, in tabulate
    for i in range(len(rows[0])):
IndexError: list index out of range

Exact definition for the download count

Hi There,

thanks for this package, very helpful. It's unclear to me exactly what is being output by this tool? Is it a sum of download counts from various sources? How does that differ from "pip only" option -p? Is there a way to get unique download count etc? Some more details would be helpful.

The default output for my packages is almost 6-10 times higher than if use the --pip option - any idea on why is that? I only ever recommended people to use my package via pip install. Although there are some dev, who clone and install locally outside pip, that number is likely very small. So the --pip option should closely match the default count (unless there is lot more going on which I don't understand).

Also, if I would like to estimate "usage" (which is a higher bar from download) from this, would it make sense?

Thanks for your help.

SyntaxError: invalid syntax: headers, *data = rows:

I just pip-installed and I'm getting

Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 7, in <module>
    from pypinfo.cli import pypinfo
  File "/usr/local/lib/python2.7/dist-packages/pypinfo/cli.py", line 3, in <module>
    from pypinfo.core import build_query, create_client, format_json, parse_query_result, tabulate
  File "/usr/local/lib/python2.7/dist-packages/pypinfo/core.py", line 118
    headers, *data = rows
             ^
SyntaxError: invalid syntax

Non-normalised package name

I would like to use the data to correlate with openSUSE package names, which use the 'real' name supplied in setup.py, i.e. not-normalised.

I've been doing a bit of research at hugovk/top-pypi-packages#4 and psincraian/pepy#128, and the raw data from bigquery can include this, with a very small perf hit.

The query only needs to change from selecting file.project to substr(max(file.filename),1,LENGTH(file.project)) , or more likely including both.

Note this does depend on using standard SQL ( #28 ).

Do we know the cost implications of those changes?

Try to filter out mirror and bot downloads by default

Hi,

I tried your project and thik it's really cool. I maintain a small project with few download. When I queried the dataset for the last year it said 20k downloads. This most likely includes spiders and PyPI mirrors. For this to be useful for smaller projects it would be great to try and filter these things out by default.

I for instance have downloads from Python version 1.17, which does not seem right. The majority of my downloads come from the system None (which I assume happens when downloaded over HTTP by clicking the link on the website. Maybe a baseline could be computed based on the minimum number of downloads for any project during the same time interval?

sytematic error when i use --auth

When i run pypinfo --auth key.json with the BigQuery key i have the given answer :

$ pypinfo --auth key.json
Traceback (most recent call last):
  File "~/.local/bin/pypinfo", line 8, in <module>
    sys.exit(pypinfo())
  File "~/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "~/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "~/.local/lib/python3.8/site-packages/click/core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "~/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "~/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "~/.local/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "~/.local/lib/python3.8/site-packages/pypinfo/cli.py", line 119, in pypinfo
    set_credentials(auth)
  File "~/.local/lib/python3.8/site-packages/pypinfo/db.py", line 25, in set_credentials
    tr.insert({'path': creds_file})
  File "~/.local/lib/python3.8/site-packages/tinyrecord/transaction.py", line 86, in __exit__
    self.record.execute()
  File "~/.local/lib/python3.8/site-packages/tinyrecord/changeset.py", line 21, in execute
    data = self.db._read()
AttributeError: 'Table' object has no attribute '_read'

There is probably something about tinydb package

Support a Python API

I would like to use this within a Python application rather than CLI. I've created a callable function modeled after pypinfo.cli.pypinfo, that returns the result rows. This works for me, but I wonder if you have better ideas about how to design that.

new option start-month (or: allow incomplete date YYYY-MM)

This is possibly related to #47 as well as #48.

I would like to have statistics for each month, and this is achievable throught --start-date and --end-date options, but for convenience it would be nice to be able to just specify the month like 2018-10.

This could be either done using a new option --start-month or by allowing a start-date without the DD, that is automatically extended to first day of the month when used for start-date and to last day of the month when used as end-date.
For both ways, start-month or incomplete start-date, the end-month or end-date should be automatically set to the (last day of the) same month by default, but changeable by the user.

Does this make sense?

Pypinfo Error - 400 FROM clause with table wildcards matches no table

Hello,

I have been running pypinfo everymonth to download stats and have had no issues untill April

I started seeing this issue 'google.api_core.exceptions.BadRequest: 400 FROM clause with table wildcards matches no table'

Has the underlying table changed? Also it logs the below query.

Any guidance ?

SELECT
file.version as version,
 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 = "<myprojectname>"
 AND details.installer.name = "pip"
GROUP BY
 version,
ORDER BY
 download_count DESC
LIMIT 10

google.api_core.exceptions.BadRequest: 400 FROM clause with table wildcards matches no table

Hi Everyone, I am getting this error despite being on the latest version:

Installing collected packages: pypinfo
Successfully installed pypinfo-19.0.0

WARNING: You are using pip version 21.1.2; however, version 21.2.4 is available.
You should consider upgrading via the '/Users/Reddy/anaconda3/envs/py36/bin/python -m pip install --upgrade pip' command.

(base) $ 16:37:33 Quark doc >>  pypinfo confounds
Traceback (most recent call last):
  File "/Users/Reddy/anaconda3/bin/pypinfo", line 11, in <module>
    sys.exit(pypinfo())
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/pypinfo/cli.py", line 150, in pypinfo
    query_rows = query_job.result(timeout=timeout // 1000)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/google/cloud/bigquery/job.py", line 2762, in result
    super(QueryJob, self).result(timeout=timeout)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/google/cloud/bigquery/job.py", line 703, in result
    return super(_AsyncJob, self).result(timeout=timeout)
  File "/Users/Reddy/anaconda3/lib/python3.6/site-packages/google/api_core/future/polling.py", line 127, in result
    raise self._exception
google.api_core.exceptions.BadRequest: 400 FROM clause with table wildcards matches no table
(base) $ 16:37:43 Quark doc >>

appreciate your help or fix!

Originally posted by @raamana in #114 (comment)

output statistics as json

Cool project!

Could you add an option to output the statistics as json? I'd like to parse/use the data in another program.

Syntax error?

So I got through the relatively painless google sign up bit.
Did a successful pip install then this happens:

visnet-57:~ iam$ pypinfo
Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 7, in <module>
    from pypinfo.cli import pypinfo
  File "/usr/local/lib/python2.7/site-packages/pypinfo/cli.py", line 3, in <module>
    from pypinfo.core import build_query, create_client, format_json, parse_query_result, tabulate, add_percentages
  File "/usr/local/lib/python2.7/site-packages/pypinfo/core.py", line 148
    headers, *data = rows
             ^
SyntaxError: invalid syntax

Is this user error? Yes

pip3 install pypinfo

worked like a charm

Fresh installation - first query fails with an exception

I just created a brand-new venv pypistats and installed pypinfo into it. Running a query from the examples results in an exception:

pypistats ~/projects/pypistats  $ pip install pypinfo
Collecting pypinfo
  Downloading pypinfo-16.0.1-py3-none-any.whl (13 kB)
Collecting tinyrecord
  Downloading tinyrecord-0.2.0.tar.gz (5.6 kB)
Collecting click
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 89 kB/s 
Collecting appdirs
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting binary
  Downloading binary-1.0.0-py2.py3-none-any.whl (9.2 kB)
Collecting tinydb<4
  Downloading tinydb-3.15.2-py2.py3-none-any.whl (17 kB)
Collecting google-cloud-bigquery>=0.29.0
  Downloading google_cloud_bigquery-1.25.0-py2.py3-none-any.whl (169 kB)
     |████████████████████████████████| 169 kB 257 kB/s 
Collecting google-cloud-core<2.0dev,>=1.1.0
  Downloading google_cloud_core-1.3.0-py2.py3-none-any.whl (26 kB)
Collecting google-api-core<2.0dev,>=1.15.0
  Downloading google_api_core-1.21.0-py2.py3-none-any.whl (90 kB)
     |████████████████████████████████| 90 kB 276 kB/s 
Collecting google-resumable-media<0.6dev,>=0.5.0
  Downloading google_resumable_media-0.5.1-py2.py3-none-any.whl (38 kB)
Collecting six<2.0.0dev,>=1.13.0
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting protobuf>=3.6.0
  Downloading protobuf-3.12.2-cp38-cp38-manylinux1_x86_64.whl (1.3 MB)
     |████████████████████████████████| 1.3 MB 289 kB/s 
Collecting google-auth<2.0dev,>=1.9.0
  Downloading google_auth-1.18.0-py2.py3-none-any.whl (90 kB)
     |████████████████████████████████| 90 kB 259 kB/s 
Collecting googleapis-common-protos<2.0dev,>=1.6.0
  Downloading googleapis_common_protos-1.52.0-py2.py3-none-any.whl (100 kB)
     |████████████████████████████████| 100 kB 236 kB/s 
Collecting requests<3.0.0dev,>=2.18.0
  Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Requirement already satisfied: setuptools>=34.0.0 in /disk2/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages (from google-api-core<2.0dev,>=1.15.0->google-cloud-bigquery>=0.29.0->pypinfo) (49.2.0)
Collecting pytz
  Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 295 kB/s 
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.1.1-py3-none-any.whl (10 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 291 kB/s 
Collecting rsa<5,>=3.1.4; python_version >= "3"
  Downloading rsa-4.6-py3-none-any.whl (47 kB)
     |████████████████████████████████| 47 kB 322 kB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 332 kB/s 
Building wheels for collected packages: tinyrecord
  Building wheel for tinyrecord (setup.py) ... done
  Created wheel for tinyrecord: filename=tinyrecord-0.2.0-py3-none-any.whl size=5906 sha256=bfc555a6e38a138609331d3157f564ed452ff519560fbfccca8121062c8dee87
  Stored in directory: /home/vinay/.cache/pip/wheels/f7/70/8f/ed3793264c07aff8cc7bd7236be77becc24c410f976ee6fc55
Successfully built tinyrecord
Installing collected packages: tinyrecord, click, appdirs, binary, tinydb, cachetools, pyasn1, pyasn1-modules, rsa, six, google-auth, protobuf, googleapis-common-protos, urllib3, idna, chardet, certifi, requests, pytz, google-api-core, google-cloud-core, google-resumable-media, google-cloud-bigquery, pypinfo
Successfully installed appdirs-1.4.4 binary-1.0.0 cachetools-4.1.1 certifi-2020.6.20 chardet-3.0.4 click-7.1.2 google-api-core-1.21.0 google-auth-1.18.0 google-cloud-bigquery-1.25.0 google-cloud-core-1.3.0 google-resumable-media-0.5.1 googleapis-common-protos-1.52.0 idna-2.10 protobuf-3.12.2 pyasn1-0.4.8 pyasn1-modules-0.2.8 pypinfo-16.0.1 pytz-2020.1 requests-2.24.0 rsa-4.6 six-1.15.0 tinydb-3.15.2 tinyrecord-0.2.0 urllib3-1.25.9
pypistats ~/projects/pypistats  $ pypinfo --auth pypi-stats.json --days 365 "" project
Traceback (most recent call last):
  File "/home/vinay/.local/share/virtualenvs/pypistats/bin/pypinfo", line 8, in <module>
    sys.exit(pypinfo())
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/click/core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/pypinfo/cli.py", line 119, in pypinfo
    set_credentials(auth)
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/pypinfo/db.py", line 25, in set_credentials
    tr.insert({'path': creds_file})
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/tinyrecord/transaction.py", line 79, in __exit__
    self.record.execute()
  File "/home/vinay/.local/share/virtualenvs/pypistats/lib/python3.8/site-packages/tinyrecord/changeset.py", line 25, in execute
    self.table._update_table(updater)
AttributeError: 'Table' object has no attribute '_update_table'

Service account credentials & BigQuery API activation instructions appear out of date

I think the README instructions on enabling BigQuery for the service account are out of date. I didn't see any way to activate BigQuery access during the credential generation process.

As best I can tell, what worked for me was setting the following in the Google Cloud project settings:

  1. In IAM & Admin > IAM, add the newly created service account/credential to the permissions list, and give it Owner permissions
  2. In "APIs & Services" > "Dashboard", click ENABLE APIS AND SERVICES, select BigQuery API from the list, and click ENABLE

google-cloud-bigquery 0.29.0: AttributeError: 'QueryJob' object has no attribute 'query_results'

I upgraded google-cloud-bigquery and get AttributeError: 'QueryJob' object has no attribute 'query_results'.

This also happens when installing pypinfo in a fresh environment.

Downgrading back to the previous 0.28.0 works.

$ python --version
Python 3.6.4
$ pypinfo --version
pypinfo, version 7.0.0

Upgrade to google-cloud-bigquery==0.29.0

$  pip install -U google-cloud-bigquery
Collecting google-cloud-bigquery
  Downloading google_cloud_bigquery-0.29.0-py2.py3-none-any.whl (67kB)
    100% |████████████████████████████████| 71kB 890kB/s
Collecting google-api-core<0.2.0dev,>=0.1.1 (from google-cloud-bigquery)
  Downloading google_api_core-0.1.3-py2.py3-none-any.whl (49kB)
    100% |████████████████████████████████| 51kB 1.8MB/s
Requirement already up-to-date: requests>=2.18.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery)
Requirement already up-to-date: google-cloud-core<0.29dev,>=0.28.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery)
Requirement already up-to-date: google-auth>=1.0.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery)
Requirement already up-to-date: google-resumable-media>=0.2.1 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery)
Collecting protobuf>=3.0.0 (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery)
  Downloading protobuf-3.5.1-py2.py3-none-any.whl (388kB)
    100% |████████████████████████████████| 389kB 1.1MB/s
Collecting pytz (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery)
  Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
    100% |████████████████████████████████| 512kB 1.3MB/s
Requirement already up-to-date: googleapis-common-protos<2.0dev,>=1.5.3 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery)
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery)
Collecting setuptools>=34.0.0 (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery)
  Using cached setuptools-38.4.0-py2.py3-none-any.whl
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages/chardet-3.0.4-py3.6.egg (from requests>=2.18.0->google-cloud-bigquery)
Requirement already up-to-date: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery)
Requirement already up-to-date: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery)
Requirement already up-to-date: idna<2.7,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery)
Requirement already up-to-date: pyasn1-modules>=0.0.5 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery)
Requirement already up-to-date: pyasn1>=0.1.7 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery)
Requirement already up-to-date: rsa>=3.1.4 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery)
Requirement already up-to-date: cachetools>=2.0.0 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery)
Installing collected packages: setuptools, protobuf, pytz, google-api-core, google-cloud-bigquery
  Found existing installation: setuptools 38.2.5
    Uninstalling setuptools-38.2.5:
      Successfully uninstalled setuptools-38.2.5
  Found existing installation: protobuf 3.5.0.post1
    Uninstalling protobuf-3.5.0.post1:
      Successfully uninstalled protobuf-3.5.0.post1
  Found existing installation: pytz 2017.2
    Uninstalling pytz-2017.2:
      Successfully uninstalled pytz-2017.2
  Found existing installation: google-api-core 0.1.1
    Uninstalling google-api-core-0.1.1:
      Successfully uninstalled google-api-core-0.1.1
  Found existing installation: google-cloud-bigquery 0.28.0
    Uninstalling google-cloud-bigquery-0.28.0:
      Successfully uninstalled google-cloud-bigquery-0.28.0
Successfully installed google-api-core-0.1.3 google-cloud-bigquery-0.29.0 protobuf-3.5.1 pytz-2017.3 setuptools-38.4.0
$ pip freeze | grep google
google-api-core==0.1.3
google-auth==1.2.1
google-cloud-bigquery==0.29.0
google-cloud-core==0.28.0
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3
$ pypinfo --percent --pip --markdown packaging pyversion
Traceback (most recent call last):
  File "/usr/local/bin/pypinfo", line 11, in <module>
    load_entry_point('pypinfo', 'console_scripts', 'pypinfo')()
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/hugo/github/pypinfo/pypinfo/cli.py", line 103, in pypinfo
    rows = parse_query_result(query_job, query_rows)
  File "/Users/hugo/github/pypinfo/pypinfo/core.py", line 98, in parse_query_result
    rows = [[field.name for field in query_job.query_results().schema]]
AttributeError: 'QueryJob' object has no attribute 'query_results'

Downgrade to google-cloud-bigquery==0.28.0

$ pip install google-cloud-bigquery==0.28.0
ollecting google-cloud-bigquery==0.28.0
  Using cached google_cloud_bigquery-0.28.0-py2.py3-none-any.whl
Requirement already satisfied: google-auth>=1.0.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery==0.28.0)
Requirement already satisfied: google-resumable-media>=0.2.1 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery==0.28.0)
Requirement already satisfied: google-api-core<0.2.0dev,>=0.1.1 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery==0.28.0)
Requirement already satisfied: requests>=2.18.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery==0.28.0)
Requirement already satisfied: google-cloud-core<0.29dev,>=0.28.0 in /usr/local/lib/python3.6/site-packages (from google-cloud-bigquery==0.28.0)
Requirement already satisfied: rsa>=3.1.4 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: pyasn1>=0.1.7 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: pyasn1-modules>=0.0.5 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: cachetools>=2.0.0 in /usr/local/lib/python3.6/site-packages (from google-auth>=1.0.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: setuptools>=34.0.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery==0.28.0)
Requirement already satisfied: protobuf>=3.0.0 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery==0.28.0)
Requirement already satisfied: googleapis-common-protos<2.0dev,>=1.5.3 in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery==0.28.0)
Requirement already satisfied: pytz in /usr/local/lib/python3.6/site-packages (from google-api-core<0.2.0dev,>=0.1.1->google-cloud-bigquery==0.28.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages/chardet-3.0.4-py3.6.egg (from requests>=2.18.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery==0.28.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests>=2.18.0->google-cloud-bigquery==0.28.0)
Installing collected packages: google-cloud-bigquery
  Found existing installation: google-cloud-bigquery 0.29.0
    Uninstalling google-cloud-bigquery-0.29.0:
      Successfully uninstalled google-cloud-bigquery-0.29.0
Successfully installed google-cloud-bigquery-0.28.0
$ pip freeze | grep google
google-api-core==0.1.3
google-auth==1.2.1
google-cloud-bigquery==0.28.0
google-cloud-core==0.28.0
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3
$ pypinfo --percent --pip --markdown packaging pyversion

| python_version | percent | download_count |
| -------------- | ------: | -------------: |
| 2.7            |   69.0% |        504,306 |
| 3.4            |   11.3% |         82,356 |
| 3.6            |    9.3% |         67,912 |
| 3.5            |    5.9% |         42,973 |
| 2.6            |    4.1% |         30,254 |
| 3.3            |    0.3% |          1,852 |
| 3.7            |    0.1% |            761 |
| None           |    0.0% |             31 |
| 3.2            |    0.0% |              1 |

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.