I just installed Anaconda (with Python 3 as default), as I need it for pandas/accessing Google Analytics. Here is some info about accessing GA through Python & pandas: http://pandas.pydata.org/pandas-docs/stable/remote_data.html#remote-data-ga
A similar question was asked here Google API client secrets error (Python) but the answer does not seem helpful in my particular case. Namely, the error I have is different; I've placed the client_secrets.json file in the appropriate directory; the file is not empty and has the exact same contents as shown in the developer console.
Here is the code and error:
import numpy as np
import pandas as pd
import pandas.io.ga as ga
from pandas import Series, DataFrame
df = ga.read_ga(metrics='sessions', dimensions='date', start_date='2015-07-01')
An exception has occurred, use %tb to see the full traceback.
SystemExit:
WARNING: Please configure OAuth 2.0
You need to populate the client_secrets.json file found at:
/Users/usernamehere/anaconda/envs/py2/lib/python2.7/site-packages/pandas/io/client_secrets.json
with information from the APIs Console <https://code.google.com/apis/console>.
Some extra details about the setup:
Besides Anaconda, I've also installed the Google API library and GFlags
It appears GFlags is not compatible with Python 3, so I created a new environment using the conda create method
The Google account used to access the Google Developer Console has two-factor auth enabled
Looks like Google Developer Console used to provide default URI redirects, but not anymore.
When setting up client secrets, make sure to add the following to "Authorized redirect URIs":
http://localhost:8080/
This has to be exact--even a missing / will cause errors. One way to check this is to make sure the client_secrets.json file has this line:
"redirect_uris":["http://localhost:8080/"]
Related
Built a flask app that works when I run it locally (Windows 10). Deployment through local git is successful, but when I try to visit the url, all I see if Application Error. So when I check the log stream, it shows that the app breaks down when it tries to import pyodbc with the error "ImportError libodbc.so.2: cannot open shared object file."
So I SSH'ed into the container, activated the virtual environment, called open python and called import pyodbc and it worked. Now I'm confused as to why it would fail when I try to visit the URL, vs when I SSH and import pyodbc myself it would work. I'm not sure if I've provided enough detail so let me know if I should add anything else.
What is going on? How do I fix my container so that it can import pyodbc?
#user152836 - Can you please let us know the following information to debug further:
Version of python that you are using in your web app? Native or extension?
OS of your web app?
If you installed a python extension, the problem could be that azure web app uses default python which does not have the pyodbc driver. In order to use the python extension you can follow this thread - install odbc driver to azure app service
You also need to export the relevant LD LIBRARY path and add it in your bash profile file as in this example:
Python executable not finding libpython shared library
If the above two suggestions don't work, you can also check this link: pyodbc - error while running application within a container
I've been trying to install Plot.ly Python SDK, I have it included in the requirements.txt but still fails and I get a Page Not Found error when calling a page served by Flask.
The problem with Plot.ly is that it requires the credentials to be installed:
import plotly
plotly.tools.set_credentials_file(username='SomeDemoAccount', api_key='SomeAPIKey')
And this won't run in as a code, not from ssh in the console because the instance doesn't has access to the ~/.plotly/.credentials file, i.e. it can't create it nor access it, so any call to the API will always fail. In AWS logs you'll get the following error:
Looks like you don't have 'read-write' permission to your 'home' ('~') directory or to our '~/.plotly' directory. That means plotly's python api can't setup local configuration files. No problem though! You'll just have to sign-in using 'plotly.plotly.sign_in()'. For help with that: 'help(plotly.plotly.sign_in)'.
So the solution is to call the plotly.plotly.sign_in() method that it's not even mentioned in their getting started guide nor the API reference, and it must be called with following arguments:
plotly.plotly.sign_in("Your Plotly Username","Your Plotly API Key")
That I implemented by having those values as EB Environment Properties:
plotly.plotly.sign_in(os.environ['YOUR_PLOTLY_USERNAME_ENV_PROPERTY_NAME'],os.environ['YOUR_PLOTLY_API_KEY_ENV_PROPERTY_NAME'])
Struggling to finish building out a python script intended to pull a few lines of text from 3 different columns in a Google spreadsheet.
When I run the script, I get the following error message:
File "pr_email_robot.py", line 2, in <module>
import gspread
ImportError: No module named gspread
Pats-MacBook-Pro:pr-email-robot-master patahern$
The area of code that must be off is:
import smtplib
import gspread
from gmail_variables import *
gc = gspread.login(GMAIL_USERNAME, GMAIL_PASSWORD)
wks = gc.open("PR-Command-Line-Emails").sheet1
recipients = wks.get_all_values()
I'm guessing that I have the wrong terminology to pull the Google Spreadsheet, but I can't find anything online about what to put in place of "gspread"
Thanks in advance for your help!
Have you tried using Google Fusion Tables (still in beta)? You can query Google Fusion Tables' Rest API using SQL syntax and urllib's urllib.request.urlopen() to issue GET and POST requests. If you are heart set on using Google Sheets, the Google Sheets API looks like it functions in much of the same way as Google Fusion Tables REST API. Meaning, you can still use the built in urllib Python library to issue GET and POST requests to the Sheets API.
It may also be helpful to note that Google has posted a Getting Started in Python Guide for the Google Sheets API. The example shown there, has no mention of any "gspread" imports.
You need to make sure you have the gspread module installed somewhere your Python installation will find it.
If you have pip:
pip install gspread
will make sure that it's installed.
ALSO
Gspread no longer supports using email/login for authentication, and relies on OAuth2 for authentication.
Check out how to set that up here.
Then check out the gspread docs for how to access info from your sheet!
I am using netsight.windowsauthplugin version 2.3.1 in my Plone CMS installation on a linux server. The domain/realm is a windows domain.
My sysadmin gave me a .keytab file and set up the DNS A and PTR record, I have configured /etc/krb5.conf (the same way I have it for a spring java webapp on an another server), configured zope, but when I try to log in with Intrernet Explorer from my pc, I get an error:
GSSError: (('Unspecified GSS failure. Minor code may provide more
information', 851968), ('No key table entry found matching HTTP/#',
39756033))
What am I missing? My plone python interpreter cannot resolv a proper name? It cannot read the keytab or krb5.conf file?
There's a lot that can/could go wrong (or has to go right) before SSO works. To focus directly on your error report it seems that the PAS plugin in Plone cannot correctly get the GSSAPI service name.
In the latest master version on github (https://github.com/netsight/netsight.windowsauthplugin) there is a 'GSSAPI service' property you can add to the SPNEGO object stored in acl_users. Use this version and set the GSSAPI Service property to 'HTTP#www.mydomain.com'.
Note the '#' here, I think this is also wrong in the default value netsight.windowsauthplugin calculates where it adds a '/' as separator (suggesting it's an SPN, but it is the GSSAPI servide hint to the kerberos library.
If you run into other problems after this, please first try to enable kerberos library tracing by adding a KRB5_TRACE=/location/to/krbtrace-mysite.log environment variable before you start your Plone site (assuming you can run it from the terminal on some unixy environment). This KRB5_TRACE only works with newer kerberos releases but will provide you a lot more insight as to what is going wrong when you have to debug any further.
I am following getting started guide of google app engine python2.7. I have downloaded zip file of app engine for my ubuntu. I have created helloworld files and ran
'google_appengine/dev_appserver.py helloworld/'
command. localhost:8000, i.e. admin page opens fine, but localhost:8080 has server error.
I have tried to import in my local python environment, which gave an error. So do we have to install it? which I tried according to webapp2's official website but didn't work out.
This question gets asked so many times, have you checked stackoverflow for similar answers?
Have you read the documentation on what third party libraries are included with the appengine runtime.
webapp2 is included in the runtime but you must configure support/inclusion in app.yaml
https://developers.google.com/appengine/docs/python/tools/libraries27
And before you get any further read up on how to include external third party libraries. You will save yourself lots of time and questions just reading.