Google Drive Quickstart Python - Localhost didn't send any data - python

I've been following this guide:
https://developers.google.com/drive/v3/web/quickstart/python
and did everything up to the
python quickstart.py
part. When I do that it opens up a new browser (oddly not my default browser but whatever) and I get the OAuth screen, but once I click "Allow" it gives me a "localhost didn't send any data" error. The shell has:
/Library/Python/2.7/site-packages/oauth2client/_helpers.py:255:
UserWarning: Cannot access /Users/timothy.tran/.credentials/drive-
python-quickstart.json: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
0:297: execution error:
What does this mean and how can I fix it?

It means it cannot access this file:
Cannot access /Users/timothy.tran/.credentials/drive-
python-quickstart.json
because:
No such file or directory

I just got this quickstart running a while ago. When you click the oauth link generated by python commandline and it opens a random browser, copy that link and paste it in the browser where your gmail account (which you're also using in your google dev console) is currently logged-in. Let me know if you're still stuck after this.
Also I don't think you need a localhost to run this. If anything, I'd used a python virtual environment.

Related

VS Code connecting to jupyterlab server not selecting kernel

We have recently moved to a JupyterLab Server from another IDE. We are trying to get VS Code hooked up so that we can code in it rather. After much struggle, we got VS Code to connect to our remote JupyterLab server. On the status bar in the bottom, it shows
However, as soon as we connect to the JupyerLab server, all the 'run' buttons on screen disappears.
We are getting no support from our IT and have to figure it out ourselves.
A colleague suspects that it (VS Code) is not picking up the python kernel from the server. How do we go about selecting it? or pointing to it?
An additional question, how do we see and browse the folders on the JupyterLab server in VS Code?
Appreciate any assistance
I think the problem is that you didn't really connect to the remote server.
Install Remote-SSH extension. Then you can see the button on the bottom left. Click and you can connect to your service and view your folder.
You can read document about Remote-SSH for more details/
Connect to a remote Jupyter server.
According to the document about jupyter, you have to do the following steps:
Open the Kernel Picker button on the top right-hand side of the notebook (or run the Notebook: Select Notebook Kernel command from the Command Palette).
Select the Existing Jupyter Server option to connect to an existing Jupyter server.
To connect to an existing server for the first time, select Enter the URL of the running Jupyter server.
When prompted to Enter the URL of the running Jupyter server, provide the server's URI (hostname) with the authentication token included with a ?token= URL parameter. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) Alternatively, you can specify a username and password after providing the URI.

Jupyter notebook not initializing correctly without error message

I am having trouble with Jupyter Notebooks (with Anaconda) on a Windows 10 PC from work.
Yesterday I left the laptop running a little script on a Jupyter-Notebook, forgot to check it and it turned off due to battery.
Today, when I open Jupyter-Notebook I cannot use it at all. Here I share some screenshots.
The CMD output when launching Jupyter-Notebook (some info deleted since its a corporate pc, such as user).
The "landing page"
When I create a new python file.
As you can see, no error message is displayed on the cmd but the application is useless. I cannot see any existing documents or browse folders to open anything. When I start a new file it just stays in "about-blank".
I would need some help to get this working again, thanks a lot in advance!
update
When in firefox I go to the console I find that the error is generated by cookie config. It says something like
"Some cookies are making an incorrect use of recommended attribute
"SameSite" The cookie "username-localhost-8888" will be rejected soon
because it has the attribute "<SameSite" set to "none" or an invalid
value without "secure".
I have not yet found how to change this.
It also says
Uncaught TypeError: "#element".tooltip is not a function

Run Python Script (On Network Drive) as Windows Service with NSSM

I have followed around 5 tutorials on using NSSM to run a python script residing on a network drive. It creates the service, I can edit the service but when I start the service I get the following error:
Unexpected status SERVICE_STOPPED in response to START control
When I try starting the Windows-10 service from Services I get the following error:
Services error during start
I have changed the path to the python script from the full network path to a mapped network path and that did not change anything.
I have also tried using Task Scheduler which worked once in a while and was intermittent and I also tried the pywin32 method as posted here but it fails to start the service as well.
I figured it out. On my remote VM it does not allow Local System Account to be set as the Log on. It required me to add an admin user name and password. It's running now.

Can't remote debug a Python web site in Azure with vs2013

I deployed a bottle website on Azure but it shows 500 (internal error) and I can’t see the log. I refer to https://github.com/Microsoft/PTVS/wiki/Azure-Remote-Debugging to debug my project but it failed.
It shows the error message as below.
could not attach to python.exe process on Azure web site at testpybottleapp.azurewebsites.net.
Error retrieving websocket debug proxy information from web.config.
And when I try to open http://testpybottleapp.azurewebsites.net/ptvsd it said ptvsd not existed.
Have you considered using VorlonJS as well? It's a remote website debugger which may help in this case.
Alternatively, could you try grabbing a similar VM from VMDepot, uploading that, and seeing if you have the same issue? That could help us troubleshoot and understand if the issue lies in the VM itself, or one of the configuration settings.
If we want to use the remote debug on Azure for python website, we should set the publish mode as "debug". And then we should enable websocket.
Meanwhile I suggest you can try to use the debug=>Attach to Process and input wss://WSGI_PTVSD_SECRET#WEBSITE_NAME.azurewebsites.net/ptvsd. When the process (Python.exe) is shown,you can click the "Attach". Then you can open your website http://WEBSITE_NAME.azurewebsites.net in browser.
If you visit the URL like "http://mysite.azurewebsites.net/ptvsd" and get the "ptvsd not existed" error, Please double check these points:
You should publish your website as Debug mode not release mode.
Make sure the 'WSGI_PTVSD_SECRET' in local is same as the Azure website .

invalid client error from YouTube Analytics API

Original
I am trying to get top 10 videos in my channel from YouTube, so I followed the sample code from Google: https://developers.google.com/youtube/analytics/v1/code_samples/python#retrieve_top_10_videos_by_viewcount
I have installed all packages and downloaded client secrets. I typed python get_json.py in command line. (The sample script is renamed to get_json.py) This is what is showing up in command line:
WARNING:root:This function, oauth2client.tools.run(), and the use of the gflags library are deprecated and will be removed in a future version of the library.
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.readonly+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyt-analytics.readonly&
redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=849986408789-otj3v9ghdlrr24nag9c4bepei6fo0vvm.apps.googleusercontent.com&access_type=offline
If your browser is on a different machine then exit and re-run this application with the command-line parameter
--noauth_local_webserver
Then my browser pops up and I am getting this invalid_client error. Did I miss anything?
Update
I added a name in "product name" in Google API Console and reset my client secret. It works now.
It seems like you set your credentials in Google Developer Console wrong. If you are running it from a local machine, you should pick "installed application" or if from a webserver, you should specify the redirect_uri.
Also make sure YT Analytics API is turned on in the console for this project.

Categories