RE: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-05 Thread Deborah Swanson
MRAB wrote, on February 05, 2017 4:34 PM
> 
> On 2017-02-06 00:08, Deborah Swanson wrote:
> > Hi David,
> >
> > Well, I really don't know the first thing about Macs, but it looks 
> > like you got the download and environment variable right, at least 
> > it's not complaining about that.
> >
> > Looks like the current problem is with the parameters 
> you're passing 
> > to the build() function. I don't have the apiclient module 
> installed, 
> > so I can't look at it for myself, but here is the critical error:
> >
> > build() takes at most 2 positional arguments (3 given)
> >
> > This means that you've given too many parameters to 
> build(). I'm a bit 
> > confused because your youtube_search()code is calling build() with:
> >
> > youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, 
> > developerKey=DEVELOPER_KEY),
> >
> > which is passing 3 arguments,
> 
> That's 2 positional arguments and 1 keyword argument.

Well, I said I'm not an experienced python coder, and in this case I've
always seen 'self' as the unspecified argument, but it could be a key
argument. Would be nice to see all of the code and messages. And getting
a look at the build() function would tell it all.

>  > and you're using
> >
> > youtube = build(YOUTUBE_API_SERVICE_NAME, 
> > GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION, 
> > developerKey=DEVELOPER_KEY),
> >
> > which is passing 4 arguments.
> 
> That's 3 positional arguments and 1 keyword argument.
> 
>  > In either case the error you're getting is
> > complaining that build() only takes 2 arguments, so it's 
> not matching 
> > up with either youtube_search's code or your call to build().
> >
> 
> It's expecting at most 2 positional arguments. Any additional 
> arguments 
> would have to be keyword arguments.
> 
> [snip]
> 

If you're right that the error message says build() is expecting 2
positional arguments and 1 keyword argument, then simply dropping the
GOOGLE_APPLICATION_CREDENTIALS argument might just work. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-05 Thread MRAB

On 2017-02-06 00:08, Deborah Swanson wrote:

Hi David,

Well, I really don't know the first thing about Macs, but it looks like
you got the download and environment variable right, at least it's not
complaining about that.

Looks like the current problem is with the parameters you're passing to
the build() function. I don't have the apiclient module installed, so I
can't look at it for myself, but here is the critical error:

build() takes at most 2 positional arguments (3 given)

This means that you've given too many parameters to build(). I'm a bit
confused because your youtube_search()code is calling build() with:

youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY),

which is passing 3 arguments,


That's 2 positional arguments and 1 keyword argument.

> and you're using


youtube = build(YOUTUBE_API_SERVICE_NAME,
GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY),

which is passing 4 arguments.


That's 3 positional arguments and 1 keyword argument.

> In either case the error you're getting is

complaining that build() only takes 2 arguments, so it's not matching up
with either youtube_search's code or your call to build().



It's expecting at most 2 positional arguments. Any additional arguments 
would have to be keyword arguments.


[snip]

--
https://mail.python.org/mailman/listinfo/python-list


RE: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-05 Thread Deborah Swanson
Hi David,
 
Well, I really don't know the first thing about Macs, but it looks like
you got the download and environment variable right, at least it's not
complaining about that.
 
Looks like the current problem is with the parameters you're passing to
the build() function. I don't have the apiclient module installed, so I
can't look at it for myself, but here is the critical error:
 
build() takes at most 2 positional arguments (3 given)
 
This means that you've given too many parameters to build(). I'm a bit
confused because your youtube_search()code is calling build() with:
 
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY), 
 
which is passing 3 arguments, and you're using 
 
youtube = build(YOUTUBE_API_SERVICE_NAME,
GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY), 
 
which is passing 4 arguments. In either case the error you're getting is
complaining that build() only takes 2 arguments, so it's not matching up
with either youtube_search's code or your call to build().
 
It looks like you don't need the GOOGLE_APPLICATION_CREDENTIALS
argument, but more serious than that is the build() that youtube_search
is calling only takes 2 arguments and the script is calling with 3
arguments. So the script is fundamentally flawed to begin with.
 
If you want to proceed with this script, you need to get a look at the
build() function to see what arguments it wants.  You can try altering
the script to call build with only the arguments it will use, and try
that. But I suspect there are deeper problems, most likely that
apiclient.discovery version yo have insalled is either newer or older
than this youtube_search is expecting, in which case all bets are off on
making this combination work.
 
So you have 2 choices that I see, either getting a look at what the
build() you have installed uses and try youtube_search with that, or
looking for other versions of apiclient and getting a look at their
.discovery submodule build() functions. If you find a build() taking 3
arguments, you could try importing that version of apiclient.discovery
with this youtube_search. 
 
But all in all, if I had this problem I'd back up to what I really want
to accomplish and try another approach to the problem. It may not be
worth all the futzing around to make this youtube_search work.
 
Deborah
 
David Amadi wrote, on February 05, 2017 2:45 PM:

If I understand your previous email well, I've created the bits I
highlighted below and I'm still getting error messages - see below.


I'm running the python script on a Macbook Pro.

DEVELOPER_KEY = "AIza*"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
GOOGLE_APPLICATION_CREDENTIALS = "/Users/*path*/Downloads/Youtube
API-67ty5.json"


def youtube_search(options):
youtube = build(YOUTUBE_API_SERVICE_NAME,
GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)


And here's the error message that was printed on my console:


build() takes at most 2 positional arguments (3 given)

Traceback (most recent call last):

  File "/Users/*path*/ML with Python/youtube_search.py", line 71, in


youtube_search(args)

  File "/Users/*path*/ML with Python/youtube_search.py", line 19, in
youtube_search

youtube = build(YOUTUBE_API_SERVICE_NAME,
GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)

  File
"/Users/*path*/anaconda/lib/python3.5/site-packages/oauth2client/_helper
s.py", line 133, in positional_wrapper

return wrapped(*args, **kwargs)

  File
"/Users/*path*/anaconda/lib/python3.5/site-packages/googleapiclient/disc
overy.py", line 223, in build

requested_url, discovery_http, cache_discovery, cache)

  File
"/Users/*path*/anaconda/lib/python3.5/site-packages/googleapiclient/disc
overy.py", line 270, in _retrieve_discovery_doc

resp, content = http.request(actual_url)

AttributeError: 'str' object has no attribute 'request'










On 5 February 2017 at 19:58, Deborah Swanson 
wrote:


OK David,

I'm also a Linux newbie and my Linux PC has a dead power supply that
I've been too sick to fix. Since it is a choice (given my limited energy
resources), I've spent my time learning python on a very old Windows PC
instead of reviving the Linux PC, and I've never used Google Apps.

However, looking at the links provided, this is how I'd proceed:

1) At
https://developers.google.com/
 identity/protocols/application-default-cre
dentials (Google Application Default Credentials  |  Google Identity
Platform), are the insructions you need to follow.

Now, I think you make up your own path and filename for the environment
variable, the more iffy question is what file it shoud be.

And the answer appears to be that it's a file you download. It then
tells you to follow several instructions, using the
https://console.developers.

Re: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-05 Thread Amadi, David
If I understand your previous email well, I've created the bits I
highlighted below and I'm still getting error messages - see below.

I'm running the python script on a Macbook Pro.

*DEVELOPER_KEY = "AIza*"*
*YOUTUBE_API_SERVICE_NAME = "youtube"*
*YOUTUBE_API_VERSION = "v3"*
*GOOGLE_APPLICATION_CREDENTIALS = "/Users/*path*/Downloads/Youtube
API-67ty5.json"*

*def youtube_search(options):*
*youtube = build(YOUTUBE_API_SERVICE_NAME,
GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)*


*And here's the error message that was printed on my console:*

build() takes at most 2 positional arguments (3 given)

Traceback (most recent call last):

  File "/Users/*path*/ML with Python/youtube_search.py", line 71, in


youtube_search(args)

  File "/Users/*path*/ML with Python/youtube_search.py", line 19, in
youtube_search

youtube = build(YOUTUBE_API_SERVICE_NAME,
GOOGLE_APPLICATION_CREDENTIALS, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)

  File
"/Users/*path*/anaconda/lib/python3.5/site-packages/oauth2client/_helpers.py",
line 133, in positional_wrapper

return wrapped(*args, **kwargs)

  File
"/Users/*path*/anaconda/lib/python3.5/site-packages/googleapiclient/discovery.py",
line 223, in build

requested_url, discovery_http, cache_discovery, cache)

  File
"/Users/*path*/anaconda/lib/python3.5/site-packages/googleapiclient/discovery.py",
line 270, in _retrieve_discovery_doc

resp, content = http.request(actual_url)

AttributeError: 'str' object has no attribute 'request'






On 5 February 2017 at 19:58, Deborah Swanson 
wrote:

> OK David,
>
> I'm also a Linux newbie and my Linux PC has a dead power supply that
> I've been too sick to fix. Since it is a choice (given my limited energy
> resources), I've spent my time learning python on a very old Windows PC
> instead of reviving the Linux PC, and I've never used Google Apps.
>
> However, looking at the links provided, this is how I'd proceed:
>
> 1) At
> https://developers.google.com/identity/protocols/application-default-cre
> dentials (Google Application Default Credentials  |  Google Identity
> Platform), are the insructions you need to follow.
>
> Now, I think you make up your own path and filename for the environment
> variable, the more iffy question is what file it shoud be.
>
> And the answer appears to be that it's a file you download. It then
> tells you to follow several instructions, using the
> https://console.developers.google.com/projectselector/apis/credentials
> page, to get a file that automatically downloads to your computer.
>
> 2) It then says you have to make the environment variable
> GOOGLE_APPLICATION_CREDENTIALS, specifying that it points to the file
> you just downloaded.
>
> I don't have a working Linux machine to test this on, at least it sounds
> like you're using Linux (let me know if you're using Windows and I can
> test it there), but to permanently set an environment variable in Linux:
>
> Edit ~/.bashrc and add the line:
>
> export GOOGLE_APPLICATION_CREDENTIALS=
>
> (instructions are different for Windows, or Linux using something other
> than bash for shell scripts)
>
> That's what you need to do, and then your youtube_search.py should work
> (haha, well you can try it and see).
>
> Deborah
>
> David Amadi wrote, on February 05, 2017 9:38 AM
> >
> > Hi Deborah,
> >
> >
> > Thank you for stepping in, I appreciate it.
> >
> >
> > Here's the python code I'm working with -
> > http://codegists.com/snippet/python/youtube_searchpy_valeraradu_python
> >
> >
> > To be honest, I don't know how to define the environment
> > variable GOOGLE_APPLICATION_CREDENTIALS to point to a file
> > defining the credentials. In the python script (link in the
> > above line), you could only add the API Key, which I obtained
> > and provided - but the script won't run.
> >
> >
> > I look forward to hearing back from you.
> >
> >
> > Regards,
> > David
> >
> >
> > On 5 February 2017 at 03:16, Deborah Swanson
> >  wrote:
> >
> > david.am...@digital.beis.gov.uk wrote, on
> > Saturday, February 04, 2017 3:39 PM
> > >
> > > Hello All,
> > >
> > > I'm a newbie to python programming - got into it
> >
> > > predominately for the purposes of machine learning and data
> > mining and
> > > even though I've committed several weeks to learning the scripting
> > > language, I have struggled to fully grasp how it works.
> > >
> > > I'm looking to scrape title, video Id, view Count, like
> > Count, dislike
> > > Count, comment Count, favourite Count etc off YouTube using
> > a python
> > > script I found via an online tutorial.
> > >
> > > I have installed 'unidecode' and 'google-api-python-client'
> > packages
> > > via my terminal. I have also enabled YouTube Data Api V3 and I'm
> > > getting the error below each time I run the script.
> > >
> > > Could anyone please point me in the right direction?
> > >
> > > Thanks a lot in advance for your help

Re: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-05 Thread Amadi, David
Hi Deborah,

Thank you for stepping in, I appreciate it.

Here's the python code I'm working with -
http://codegists.com/snippet/python/youtube_searchpy_valeraradu_python

To be honest, I don't know how to define the environment variable
GOOGLE_APPLICATION_CREDENTIALS to point to a file defining the credentials.
In the python script (link in the above line), you could only add the API
Key, which I obtained and provided - but the script won't run.

I look forward to hearing back from you.

Regards,
David

On 5 February 2017 at 03:16, Deborah Swanson 
wrote:

> david.am...@digital.beis.gov.uk wrote, on
> Saturday, February 04, 2017 3:39 PM
> >
> > Hello All,
> >
> > I'm a newbie to python programming - got into it
> > predominately for the purposes of machine learning and data
> > mining and even though I've committed several weeks to
> > learning the scripting language, I have struggled to fully
> > grasp how it works.
> >
> > I'm looking to scrape title, video Id, view Count, like
> > Count, dislike Count, comment Count, favourite Count etc off
> > YouTube using a python script I found via an online tutorial.
> >
> > I have installed 'unidecode' and 'google-api-python-client'
> > packages via my terminal. I have also enabled YouTube Data
> > Api V3 and I'm getting the error below each time I run the script.
> >
> > Could anyone please point me in the right direction?
> >
> > Thanks a lot in advance for your help
> >
> > 
> > Traceback (most recent call last):
> >   File "/Users/*Path*/ML with Python/youtube_search.py", line
> > 73, in 
> > youtube_search(args)
> >   File "/Users/*Path*/ML with Python/youtube_search.py", line
> > 21, in youtube_search
> > youtube = build(YOUTUBE_API_SERVICE_NAME,
> > YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/_helpers.py", line 133, in positional_wrapper
> > return wrapped(*args, **kwargs)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> > lient/discovery.py", line 226, in build
> > credentials=credentials)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/_helpers.py", line 133, in positional_wrapper
> > return wrapped(*args, **kwargs)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> > lient/discovery.py", line 358, in build_from_document
> > credentials = _auth.default_credentials()
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> > lient/_auth.py", line 41, in default_credentials
> > return
> > oauth2client.client.GoogleCredentials.get_application_default()
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/client.py", line 1264, in get_application_default
> > return GoogleCredentials._get_implicit_credentials()
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/client.py", line 1254, in _get_implicit_credentials
> > raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
> > oauth2client.client.ApplicationDefaultCredentialsError: The
> > Application Default Credentials are not available. They are
> > available if running in Google Compute Engine. Otherwise, the
> > environment variable GOOGLE_APPLICATION_CREDENTIALS must be
> > defined pointing to a file defining the credentials. See
> > https://developers.google.com/accounts/docs/application-defaul
> t-credentials for more information.
>
> --
> Communications with the Department for Business, Innovation and Skills
> may
> be automatically logged, monitored and/or recorded for legal purposes.
> --
>
> I'm also a relatively new python coder (little over a year), but it
> seems plain to me that "The Application Default Credentials ... are
> available if running in Google Compute Engine. Otherwise, the
> environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
> pointing to a file defining the credentials. See
> https://developers.google.com/accounts/docs/application-default-credenti
> als for more information."
>
> If you're not running in Google Compute Engine, you need to make a file
> defining the credentials, and supposedly there are instructions or
> requirements in the link above.
>
> Looks like Anaconda tried to get the credentials by calling its
> _auth.default_credentials() function:
>
> credentials = _auth.default_credentials()
>
> from "python3.5/site-packages/googleapiclient/discovery.py", but it
> failed. I think you need to read that link and make the file it wants to
> find.
>
> Deborah
>
>


-- 

David Amadi

Digital Performance Analyst | Apprenticeships Service

Department for Business, Energy and Industrial Strategy


david.am...@digital.beis.gov.uk


M. 07904776300

Communications with the Department for Business, Innovation and Skills may
be automatically logged, monitored and/or recorded for legal purposes.

-- 
Communications with the 

RE: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-05 Thread Deborah Swanson
OK David,

I'm also a Linux newbie and my Linux PC has a dead power supply that
I've been too sick to fix. Since it is a choice (given my limited energy
resources), I've spent my time learning python on a very old Windows PC
instead of reviving the Linux PC, and I've never used Google Apps.

However, looking at the links provided, this is how I'd proceed:

1) At
https://developers.google.com/identity/protocols/application-default-cre
dentials (Google Application Default Credentials  |  Google Identity
Platform), are the insructions you need to follow.

Now, I think you make up your own path and filename for the environment
variable, the more iffy question is what file it shoud be.

And the answer appears to be that it's a file you download. It then
tells you to follow several instructions, using the
https://console.developers.google.com/projectselector/apis/credentials
page, to get a file that automatically downloads to your computer.

2) It then says you have to make the environment variable
GOOGLE_APPLICATION_CREDENTIALS, specifying that it points to the file
you just downloaded. 

I don't have a working Linux machine to test this on, at least it sounds
like you're using Linux (let me know if you're using Windows and I can
test it there), but to permanently set an environment variable in Linux:

Edit ~/.bashrc and add the line:

export GOOGLE_APPLICATION_CREDENTIALS=

(instructions are different for Windows, or Linux using something other
than bash for shell scripts)

That's what you need to do, and then your youtube_search.py should work
(haha, well you can try it and see).

Deborah

David Amadi wrote, on February 05, 2017 9:38 AM
> 
> Hi Deborah,
> 
> 
> Thank you for stepping in, I appreciate it.
> 
> 
> Here's the python code I'm working with - 
> http://codegists.com/snippet/python/youtube_searchpy_valeraradu_python
> 
> 
> To be honest, I don't know how to define the environment 
> variable GOOGLE_APPLICATION_CREDENTIALS to point to a file 
> defining the credentials. In the python script (link in the 
> above line), you could only add the API Key, which I obtained 
> and provided - but the script won't run.
> 
> 
> I look forward to hearing back from you.
> 
> 
> Regards,
> David
> 
> 
> On 5 February 2017 at 03:16, Deborah Swanson 
>  wrote:
> 
> david.am...@digital.beis.gov.uk wrote, on
> Saturday, February 04, 2017 3:39 PM
> >
> > Hello All,
> >
> > I'm a newbie to python programming - got into it
> 
> > predominately for the purposes of machine learning and data 
> mining and 
> > even though I've committed several weeks to learning the scripting 
> > language, I have struggled to fully grasp how it works.
> >
> > I'm looking to scrape title, video Id, view Count, like 
> Count, dislike 
> > Count, comment Count, favourite Count etc off YouTube using 
> a python 
> > script I found via an online tutorial.
> >
> > I have installed 'unidecode' and 'google-api-python-client' 
> packages 
> > via my terminal. I have also enabled YouTube Data Api V3 and I'm 
> > getting the error below each time I run the script.
> >
> > Could anyone please point me in the right direction?
> >
> > Thanks a lot in advance for your help
> >
> > 
> > Traceback (most recent call last):
> >   File "/Users/*Path*/ML with Python/youtube_search.py", 
> line 73, in 
> > 
> > youtube_search(args)
> >   File "/Users/*Path*/ML with Python/youtube_search.py", 
> line 21, in 
> > youtube_search
> > youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, 
> > developerKey=DEVELOPER_KEY)
> >   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/_helpers.py", line 133, in positional_wrapper
> > return wrapped(*args, **kwargs)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> > lient/discovery.py", line 226, in build
> > credentials=credentials)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/_helpers.py", line 133, in positional_wrapper
> > return wrapped(*args, **kwargs)
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> 
> > lient/discovery.py", line 358, in build_from_document
> > credentials = _auth.default_credentials()
> >   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> > lient/_auth.py", line 41, in default_credentials
> > return
> > oauth2client.client.GoogleCredentials.get_application_default()
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/client.py", line 1264, in get_application_default
> > return GoogleCredentials._get_implicit_credentials()
> >   File
> > "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> > nt/client.py", line 1254, in _get_implicit_credentials
> > raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
> > oauth2client.client.ApplicationDefaultCredentialsError: The
> > Application Default Credentials are not available. They are
> 

RE: Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-04 Thread Deborah Swanson
david.am...@digital.beis.gov.uk wrote, on 
Saturday, February 04, 2017 3:39 PM
> 
> Hello All,
> 
> I'm a newbie to python programming - got into it 
> predominately for the purposes of machine learning and data 
> mining and even though I've committed several weeks to 
> learning the scripting language, I have struggled to fully 
> grasp how it works.
> 
> I'm looking to scrape title, video Id, view Count, like 
> Count, dislike Count, comment Count, favourite Count etc off 
> YouTube using a python script I found via an online tutorial.
> 
> I have installed 'unidecode' and 'google-api-python-client' 
> packages via my terminal. I have also enabled YouTube Data 
> Api V3 and I'm getting the error below each time I run the script. 
> 
> Could anyone please point me in the right direction?
> 
> Thanks a lot in advance for your help
> 
> 
> Traceback (most recent call last):
>   File "/Users/*Path*/ML with Python/youtube_search.py", line 
> 73, in 
> youtube_search(args)
>   File "/Users/*Path*/ML with Python/youtube_search.py", line 
> 21, in youtube_search
> youtube = build(YOUTUBE_API_SERVICE_NAME, 
> YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> nt/_helpers.py", line 133, in positional_wrapper
> return wrapped(*args, **kwargs)
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> lient/discovery.py", line 226, in build
> credentials=credentials)
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> nt/_helpers.py", line 133, in positional_wrapper
> return wrapped(*args, **kwargs)
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> lient/discovery.py", line 358, in build_from_document
> credentials = _auth.default_credentials()
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapic
> lient/_auth.py", line 41, in default_credentials
> return 
> oauth2client.client.GoogleCredentials.get_application_default()
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> nt/client.py", line 1264, in get_application_default
> return GoogleCredentials._get_implicit_credentials()
>   File 
> "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2clie
> nt/client.py", line 1254, in _get_implicit_credentials
> raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
> oauth2client.client.ApplicationDefaultCredentialsError: The 
> Application Default Credentials are not available. They are 
> available if running in Google Compute Engine. Otherwise, the 
> environment variable GOOGLE_APPLICATION_CREDENTIALS must be 
> defined pointing to a file defining the credentials. See 
> https://developers.google.com/accounts/docs/application-defaul
t-credentials for more information.

-- 
Communications with the Department for Business, Innovation and Skills
may 
be automatically logged, monitored and/or recorded for legal purposes.
-- 

I'm also a relatively new python coder (little over a year), but it
seems plain to me that "The Application Default Credentials ... are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials. See
https://developers.google.com/accounts/docs/application-default-credenti
als for more information."

If you're not running in Google Compute Engine, you need to make a file
defining the credentials, and supposedly there are instructions or
requirements in the link above.

Looks like Anaconda tried to get the credentials by calling its
_auth.default_credentials() function:

credentials = _auth.default_credentials()

from "python3.5/site-packages/googleapiclient/discovery.py", but it
failed. I think you need to read that link and make the file it wants to
find.

Deborah

-- 
https://mail.python.org/mailman/listinfo/python-list


Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

2017-02-04 Thread david . amadi
Hello All,

I’m a newbie to python programming – got into it predominately for the purposes 
of machine learning and data mining and even though I’ve committed several 
weeks to learning the scripting language, I have struggled to fully grasp how 
it works.

I’m looking to scrape title, video Id, view Count, like Count, dislike Count, 
comment Count, favourite Count etc off YouTube using a python script I found 
via an online tutorial.

I have installed ‘unidecode’ and 'google-api-python-client' packages via my 
terminal. I have also enabled YouTube Data Api V3 and I’m getting the error 
below each time I run the script. 

Could anyone please point me in the right direction?

Thanks a lot in advance for your help


Traceback (most recent call last):
  File "/Users/*Path*/ML with Python/youtube_search.py", line 73, in 
youtube_search(args)
  File "/Users/*Path*/ML with Python/youtube_search.py", line 21, in 
youtube_search
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, 
developerKey=DEVELOPER_KEY)
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/_helpers.py", 
line 133, in positional_wrapper
return wrapped(*args, **kwargs)
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapiclient/discovery.py",
 line 226, in build
credentials=credentials)
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/_helpers.py", 
line 133, in positional_wrapper
return wrapped(*args, **kwargs)
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapiclient/discovery.py",
 line 358, in build_from_document
credentials = _auth.default_credentials()
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapiclient/_auth.py", 
line 41, in default_credentials
return oauth2client.client.GoogleCredentials.get_application_default()
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/client.py", 
line 1264, in get_application_default
return GoogleCredentials._get_implicit_credentials()
  File 
"/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/client.py", 
line 1254, in _get_implicit_credentials
raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default 
Credentials are not available. They are available if running in Google Compute 
Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must 
be defined pointing to a file defining the credentials. See 
https://developers.google.com/accounts/docs/application-default-credentials for 
more information.

-- 
Communications with the Department for Business, Innovation and Skills may 
be automatically logged, monitored and/or recorded for legal purposes.
-- 
https://mail.python.org/mailman/listinfo/python-list