tylertreat/BigQuery-Python

No handlers could be found for logger "bigquery.client"

imzisy opened this issue · 21 comments

from bigquery import get_client

BigQuery project id as listed in the Google Developers Console.

project_id = 'project_id'

Service account email address as listed in the Google Developers Console.

service_account = 'my_id_123@developer.gserviceaccount.com'

PKCS12 or PEM key provided by Google.

key = 'key.pem'

client = get_client(project_id, service_account=service_account,
private_key_file=key, readonly=True)

JSON key provided by Google

json_key = 'key.json'

client = get_client(json_key_file=json_key, readonly=True)

Insert data into table.

rows = [
{'one': 'ein', 'two': 'zwei'}
{'id': 'NzAzYmRiY', 'one': 'uno', 'two': 'dos'},
{'id': 'NzAzYmRiY', 'one': 'ein', 'two': 'zwei'} # duplicate entry
]

inserted = client.push_rows('dataset', 'table', rows, 'id')

Hey,

I'm facing exactly the problem as the above. Could someone help us out? @tylertreat

@kumarabd use gcloud and official library instead

@imzisy Worked perfect!! thanks 👍

You client is in read only mode. Fix it!

Hi, any update on this issue? I am facing the same problem. Other than turning to gcloud, is there any solution yet? (I set readonly as False already) @tylertreat @imzisy

@bowen0603 when do you see No handlers could be found for logger "bigquery.client"?

It is when I am calling: created = client.create_table('dataset', 'my_table', schema)

The schema is a given example:
schema = [
{'name': 'foo', 'type': 'STRING', 'mode': 'nullable'},
{'name': 'bar', 'type': 'FLOAT', 'mode': 'nullable'}
]

I then check the table as well.
exists = client.check_table('dataset', 'my_table')

It turns out both created and exists are False.

I executed the same code as above, the only difference is I only use json key for get_client, not PEM. Could you give me any help on this? Thanks! @tylertreat

Hi @tylertreat, any update on this one? Could you please help me out? I have been stuck on this for a while. Thanks a lot!

Hello @bowen0603, just wondering if you had added 'readonly = False' or 'swallow_results = False' to your get_client function call? Referencing #44 (comment) it seems like the library uses readonly = True by default and you have to specify that you want to be able to write.

@bowen0603 Can you show us a minimal code which reproduce this case?

I tried following

# code fragment from client.py about logging
`--> cat logtest.py
from logging import getLogger, NullHandler

logger = getLogger('bigquery.client')
logger.addHandler(NullHandler())
logger.info("hey")

print('OK')
`--> python --version
Python 3.5.1
`--> python ./logtest.py
OK

## switch to python2
`--> pyenv shell 2.7.5

`--> python --version
Python 2.7.5
`--> python ./logtest.py
OK

but I have no error.

Yes, I did set readonly to False.

client = get_client(project_id, service_account=service_account, json_key_file=json_key, readonly=False) => this one works.

created = client.create_table('bowen_editor_attachments', 'my_table', schema) => this one gives me the "No handers could be found for logger "bigquery.client"".

Thanks for replying me :) @ciaran-blewitt-webjet @hagino3000

I created same code as next

# test.py
from bigquery import get_client

client = get_client(
    'MYPROJECT',
    json_key_file='MY_JSON_KEY_PATH',
    readonly=False
)

created = client.create_table('tmp_7day', 'libtest', [{'name': 'id', 'type': 'string'}])

print('OK')

Then, I prepare clean python environment

`--> cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
`--> virtualenv .    
New python executable in ./bin/python
Installing Setuptools........................................................................................................................
......................................................................................................done.
Installing Pip...............................................................................................................................
.............................................................................................................................................
.........................................................done.
`--> ./bin/pip install BigQuery-Python
Downloading/unpacking BigQuery-Python
  Downloading BigQuery-Python-1.10.0.tar.gz
  Running setup.py egg_info for package BigQuery-Python

Downloading/unpacking google-api-python-client (from BigQuery-Python)
  Downloading google-api-python-client-1.6.1.tar.gz (46kB): 46kB downloaded
  Running setup.py egg_info for package google-api-python-client

    warning: no files found matching '*.json' under directory 'apiclient'
    warning: no files found matching 'README'
    warning: no files found matching 'FAQ'
    warning: no files found matching 'setpath.sh'
Downloading/unpacking httplib2 (from BigQuery-Python)
  Downloading httplib2-0.9.2.zip (210kB): 210kB downloaded
  Running setup.py egg_info for package httplib2

Downloading/unpacking python-dateutil (from BigQuery-Python)
  Downloading python-dateutil-2.6.0.tar.gz (258kB): 258kB downloaded
  Running setup.py egg_info for package python-dateutil

    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.py[co]' found anywhere in distribution
Downloading/unpacking oauth2client>=1.5.0,<5.0.0dev (from google-api-python-client->BigQuery-Python)
  Downloading oauth2client-4.0.0.tar.gz (72kB): 72kB downloaded
  Running setup.py egg_info for package oauth2client

    warning: no previously-included files matching '*' found under directory 'tests'
Downloading/unpacking six>=1.6.1,<2dev (from google-api-python-client->BigQuery-Python)
  Downloading six-1.10.0.tar.gz
  Running setup.py egg_info for package six

    no previously-included directories found matching 'documentation/_build'
Downloading/unpacking uritemplate>=3.0.0,<4dev (from google-api-python-client->BigQuery-Python)
  Downloading uritemplate-3.0.0.tar.gz
  Running setup.py egg_info for package uritemplate

    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*.py[cdo]' found anywhere in distribution
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    warning: no previously-included files matching '*.pyd' found anywhere in distribution
Downloading/unpacking pyasn1>=0.1.7 (from oauth2client>=1.5.0,<5.0.0dev->google-api-python-client->BigQuery-Python)
  Downloading pyasn1-0.1.9.tar.gz (75kB): 75kB downloaded
  Running setup.py egg_info for package pyasn1

Downloading/unpacking pyasn1-modules>=0.0.5 (from oauth2client>=1.5.0,<5.0.0dev->google-api-python-client->BigQuery-Python)
  Downloading pyasn1-modules-0.0.8.tar.gz
  Running setup.py egg_info for package pyasn1-modules

Downloading/unpacking rsa>=3.1.4 (from oauth2client>=1.5.0,<5.0.0dev->google-api-python-client->BigQuery-Python)
  Downloading rsa-3.4.2.tar.gz (40kB): 40kB downloaded
  Running setup.py egg_info for package rsa

Installing collected packages: BigQuery-Python, google-api-python-client, httplib2, python-dateutil, oauth2client, six, uritemplate, pyasn1,
pyasn1-modules, rsa
  Running setup.py install for BigQuery-Python

  Running setup.py install for google-api-python-client

    warning: no files found matching '*.json' under directory 'apiclient'
    warning: no files found matching 'README'
    warning: no files found matching 'FAQ'
    warning: no files found matching 'setpath.sh'
  Running setup.py install for httplib2

  Running setup.py install for python-dateutil

    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.py[co]' found anywhere in distribution
  Running setup.py install for oauth2client

    warning: no previously-included files matching '*' found under directory 'tests'
  Running setup.py install for six

    no previously-included directories found matching 'documentation/_build'
  Running setup.py install for uritemplate

    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*.py[cdo]' found anywhere in distribution
    warning: no previously-included files matching '__pycache__' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    warning: no previously-included files matching '*.pyd' found anywhere in distribution
  Running setup.py install for pyasn1

  Running setup.py install for pyasn1-modules

  Running setup.py install for rsa

    Installing pyrsa-encrypt-bigfile script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-encrypt script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-verify script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-sign script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-priv2pub script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-decrypt script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-keygen script to /home/t-nishibayashi/tmp/test/bin
    Installing pyrsa-decrypt-bigfile script to /home/t-nishibayashi/tmp/test/bin
Successfully installed BigQuery-Python google-api-python-client httplib2 python-dateutil oauth2client six uritemplate pyasn1 pyasn1-modules rsa
Cleaning up...
`--> ./bin/python --version
Python 2.7.5

Then run it

`--> ./bin/python test.py
OK

ummmm.....

@bowen0603
Do you get the error also in a clean environment?

Yeah, I've also been unable to reproduce this issue.

Getting this issue as well. This occurs when I try to run the sample code to insert a number of rows of data into an existing table. The code is exactly the same as @imzisy's above. Anyone resolved it yet?

@niibruce What is your Python version and platform running it?

@hagino3000 Python 2.7 and macOS Sierra.

@niibruce /usr/bin/python ?

@niibruce Thanks

I reproduced this issue with following code and MacOSX python.

`--> ./bin/python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
from bigquery import get_client

client = get_client(
        'MY_PROJECT_NAME',
        json_key_file='MY_KEY_PATH',
        readonly=False
)

schema = [
    {'name': 'id', 'type': 'string'},
    {'name': 'one', 'type': 'string'},
    {'name': 'two', 'type': 'string'}
]

# Create table
created = client.create_table('tmp_7day', 'libtest4', schema)
print('Table created', created)

# Create table with same name. It will fail
created = client.create_table('tmp_7day', 'libtest4', schema)
print('Table created', created)

print('OK')

Console output

`--> ./bin/python test.py
bigquery.client
('Table created', True)
No handlers could be found for logger "bigquery.client"
('Table created', False)
OK

But this problem has fixed by this commit

@tylertreat This problem will solved by release new version.