Installing GCP SDK python Google Developer Console pre-requisite tasks Create a project, and make note of this metadata: Project ID: some-gcp-project-id

Ensure that these Google Cloud APIs are enabled on your project:  BigQuery API  Cloud Storage API  Cloud Datastore API (if you want to build out this developer environment on a Google Compute Engine, enable that API as well). Create a Google Cloud Platform (GCP) Service Account. And make note of this metadata: Client ID

some-gcp-service-acct.apps.googleusercontent.com Email address

[email protected]

For that service account generate a new P12 key (for use by gcloud.datastore, gcloud.storage), and generate a new JSON key (for use with google api client used to access BigQuery). In the process of creating these key credential files are placed in $HOME/Downloads:  some-service-acct-key.json  some-service-acct-key.p12 Subsequently, you will use the 'gcloud' command to create a key credential JSON file (which will likewise be downloaded into $HOME/Downloads) for your individual gmail account. Initially, your individual gmail account becomes the 'active', or default, credentialed user account with GCP which gcloud uses. However, it is best practice to create a credentialed GCP service account, and to configure gcloud to work with the service account. That service account becomes the new default gcloud account. As such, all Python scripts which import gcloud.datastore, gcloud.storage, and gcloud.pubsub.

Fedora 22 pre-requsite tasks You cannot install gcloud without a C compiler installed on host :q:sudo yum groupinstall 'Development Tools' Debian sudo apt-get update && apt-get upgrade sudo apt-get install build-essential

you cannot install gcloud using pip without first installing 'pycrypto' sudo yum install pycrypto

sudo apt-get install python-crypto sudo apt-get install python-dev

To complete the base modules needed by the GCP SDK, also run sudo yum install python-devel $ sudo wget https://bootstrap.pypa.io/get-pip.py $ sudo python get-pip.py $ sudo pip install --upgrade google-api-python-client httplib2 argparse

CentOS 6.6. GCE cd /usr/src sudo wget https:/www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz sudo tar xzf Python-2.7.6.tgz sudo cd Python-2.7.6 sudo ./configure sudo make altinstall

Environment Variables Set and or add the following environment variables. Most importantly, GCP SDK Python works with Python 2.7.x, which is pre-installed on Fedora 22. The Linux account running the gcloud-python scripts must use Python 2.7, and within its .bashrc file, it must set around a dozen environment variables. First, create the $PYTHONPATH environment variable and set it to the local Python 2.7 site-packages directory. # PYTHON 2.7 #export PYTHONHOME=/usr/bin/python2.7 export PYTHONPATH=/usr/lib/python2.7/site-packages Next, in order to use the GCP SDK consoles and command line tools, their location has to be appended to the existing $PATH environment variable # add gcloud bin to the $PATH

Next, in order for the Python shell or a Python script to import GCP SDK modules, their locations have to be appended to the $PTYHONPATH environment variable. # PYTHON modules for GCP SDK

export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages/gcloud export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages/gcloud/datastore export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages/gcloud/pubsub export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages/gcloud/storage export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/bq export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/gcutil export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/gcutil/lib export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/google_appengine export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/google_appengine/lib export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/gsutil export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/platform/gsutil/gslib export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/lib/googlecloudsdk/lib export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/lib/googlecloudsdk/gcloud export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/lib/googlecloudsdk/bigquery export PYTHONPATH=$PYTHONPATH:/home/yourhomedir/google-cloud-sdk/lib/googlecloudsdk/bigquery/lib

Next, append $PYTHONPATH to $PATH export PATH=$PATH:$PYTHONPATH Next, there are a number of fundamental Google Cloud SDK environment variables to add and set. First, set the CLOUDSDK_PYTHON environment variable to point to the link to Python 2.7 # Google Cloud SDK export CLOUDSDK_PYTHON=/usr/bin/python2.7 In a later set, when the 'gcloud auth login' command is run, you will be authenticating your personal gmail account with GCP, in the process 2 events happen (for which 2 different environment variables need to be set): 1- a configuration directory is created, and export CLOUDSDK_CONFIG=/home/yourhomedir/.config/gcloud 2 - a key file is downloaded to the local host. When 'gcloud auth login' runs it will ask to modify your .bashrc file, so allow it to do so. The gcloud command will add the CLOUDSDK_CONFIG environment variable to .bashrc To finish setting the credentials your personal gmail account will use when connecting to GCP, you have to add and set the GOOGLE_APPLICATION_CREDENTIALS environment variable and set it to the location of the key file that was downloaded. export GOOGLE_APPLICATION_CREDENTIALS=/home/yourhomedir/initially-your-acct-key.json export CLOUDSDK_PYTHON_SITEPACKAGES=1

Install GCP SDK Pip is used to install a number of Python modules, so if the pip command is not installed then:

sudo easy_install pip

sudo pip install gcloud that should install gcloud in /usr/lib/python2.7/site-packages/ If installing on a Google Compute Engine (GCE), the Google Cloud SDK installation directory is /usr/local/share/google/google-cloud-sdk If not, then download GCP SDK and unzip in home directory, and run this command ./google-cloud-sdk/install.sh

You also have to install google-apps, else the 'bq' command line tool will not work. sudo pip install google-apputils

Authenticate personal gmail with GCP then run gcloud auth login Ensure that these environment variables have been added and set correctly within your .bashrc file: # Google Cloud SDK export CLOUDSDK_PYTHON=/usr/bin/python2.7 export CLOUDSDK_CONFIG=/home/yourhomedir/.config/gcloud export GOOGLE_APPLICATION_CREDENTIALS=/home/yourhomedir/initially-your-acct-key.json

Configure gcloud for GCP Project Next, set the default GCP project for all gcloud scripts, so run gcloud config set project some-gcp-project-id

Update gcloud Components then run gcloud components update pkg-python then run gcloud components update pkg-java then run gcloud components update pkg-go

Configure GCP Service Account with gcloud then run to configure the service account $ gcloud auth activate-service-account [email protected] -format json --key-file /tmp/some-service-acct-key.json --project some-gcp-project-id which should return something like this:

Activated service account credentials for: [[email protected]] { "MAX_TOKEN_LIFETIME_SECS": 3600, "NON_SERIALIZED_MEMBERS": [ "store" ], "access_token": null, "access_token_expired": false, "assertion_type": null, "client_id": null, "client_secret": null, "id_token": null, "invalid": false, "refresh_token": null, "revoke_uri": "https://accounts.google.com/o/oauth2/revoke", "serialization_data": { "client_email": "[email protected]", "client_id": "some-gcp-service-acct.apps.googleusercontent.com", "private_key": "-----BEGIN PRIVATE KEY-----\n.... ......msyET7fNQ==\n-----END PRIVATE KEY-----\n", "private_key_id": "2.....3c", "type": "service_account" }, "service_account_email": "[email protected]", "service_account_name": "[email protected]", "store": {}, "token_expiry": null, "token_response": null, "token_uri": "https://accounts.google.com/o/oauth2/token", "user_agent": "Cloud SDK Command Line Tool" } Next, you will check to confirm that the GCP Service Account is 'active' and is therefore the default credentials that will be provided to gcloud Python scripts, have been downloaded into the $HOME/Downloads directory. Rename that JSON credentials file to something like some-service-acctkey.json, and place a copy of it within $HOME

Next, check that the service account is the default, or active, account within gcloud. $ gcloud auth list Credentialed accounts: - [email protected] (active) - [email protected] To set the active account, run: $ gcloud config set account ``ACCOUNT'' Next, go back into your .bashrc file and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the key (JSON file) used by the service account. The default behavior of a gcloud-python application is to reference this environment variable. export GOOGLE_APPLICATION_CREDENTIALS=/home/yourhomedir/some-service-acct-key.json

gcloud storage Query test Next, validate the GCP SDK gcloud-python configuration(s). It is critically important to note that the literal data value assigned to the datastore dataset_id is an exact literal match to the project id, in this case 'some-gcp-project-id'. If the 2 values are not an exact match the query will throw a ServiceUnavailable error, and return a stack trace. $ python Python 2.7.8 (default, Apr 15 2015, 09:26:43) [GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from gcloud import datastore >>> datastore.set_default_dataset_id('some-gcp-project-id') >>> datastore_conn = datastore.get_connection() >>> datastore.set_default_connection(datastore_conn) >>> q=datastore.Query('foo') >>> print list(q.fetch()) If everything is configured correctly, the response will be: [] Now, all we have accomplished so far is installing the Python modules that enable us to into act with Google Cloud Storage buckets and with Google Cloud Datastore. If you want to connect to Google BigQuery there are many more tasks to accomplish.

$ pip install pyopenssl ndg-httpsclient pyasn1

Installing GCP SDK python -

Apr 15, 2015 - (if you want to build out this developer environment on a Google Compute Engine, ... some-gcp-service-acct.apps.googleusercontent.com.

83KB Sizes 23 Downloads 292 Views

Recommend Documents

Installing GCP SDK python -
Apr 15, 2015 - generate a new JSON key (for use with google api client used to access ... To complete the base modules needed by the GCP SDK, also run.

Introduction Installing Python 3.0
Dec 3, 2008 - perform complex tasks and is easily extended with new functions and data types implemented in C or C++ (or ... shall open with current python version and install date and time and OS type you are using. Basics ... represented by type st

Accept SDK - GitHub
1.2.2 Activating Developer Mode . ..... Microphone access must be allowed by the user the first time the application is run in order to use the audio jack for ...

Inesoft PrintCE SDK
PrintCE.h - header file for eVC app (don't using PrintCE as ActiveX control) ... and PrintCEDriverWindowsCE.exe - automatic installer from Desktop PC to Pocket ...

SDK-80.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. SDK-80.pdf.

Accept SDK - GitHub
Accept SDK for iOS is a mPOS solution for Apple devices that enables electronic ... Accept SDK can only run on an armv7 compatible iOS device (iPhone 3GS or.

Replicator-G Sailfish 40R23 installing python and pypy -
Replicator-G Sailfish 40R23 installing python and pypy. Download the following files. http://www.thingiverse.com/thing:32084 Get the Latest Sailfish Rep-G from ...

AxeFX II GCP setup.pdf
Page 1. Whoops! There was a problem loading more pages. AxeFX II GCP setup.pdf. AxeFX II GCP setup.pdf. Open. Extract. Open with. Sign In. Main menu.

pdf sdk free
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. pdf sdk free.

SDK-85.pdf
... complete deSign library for the. SDK-85 is shown in Figure 7-11 and listed in the Specifi·. cations section under Reference Manuals. Page 3 of 6. SDK-85.pdf.

Mobile SDK Development Guide - GitHub
Jul 20, 2017 - Page 1 ..... Chapter 11: Files and Networking . ..... services. Salesforce provides the Salesforce App Cloud to address this need. This cloud ...

SDK-51.pdf
TIMING. 8051. CPU. 1 1. INTERRUPTS. 4096 BYTES. PROGRAM. MEMORY. (8051 & 8751). 64K·BYTE BUS. EXPANSION. CONTROL. CONTROL. 128 BYTES.

indian gcp guidelines pdf
Page 1 of 1. indian gcp guidelines pdf. indian gcp guidelines pdf. Open. Extract. Open with. Sign In. Main menu. Displaying indian gcp guidelines pdf.

AxeFX II GCP setup.pdf
Loading… Page 1. Whoops! There was a problem loading more pages. Retrying... AxeFX II GCP setup.pdf. AxeFX II GCP setup.pdf. Open. Extract. Open with.

word to pdf sdk
Page 1 of 1. File: Word to pdf sdk. Download now. Click here if your download doesn't start automatically. Page 1 of 1. word to pdf sdk. word to pdf sdk. Open.

Programme 2017 EU GCP Inspectors Working Group Workshop
Sep 21, 2017 - EU Portal and Database: developments. Laura Pioppo. (EMA) ... Biosimilars – Assessor's perspective: Clinical key points. Krisztian Fodor.

GCP mit neuer Region in Zürich Services
Von Urs Hölzle, SVP Technical Infrastructure. Die Schweiz ist ein Land, das für seine pharmazeutischen Produkte, seine Fertigungsindustrie und seine Banken bekannt ist und das sich wegen seiner zentralen Lage in Europa als attraktiver. Cloud-Stando

android sdk eclipse tutorial pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect ...

Corona SDK application design.pdf
BIRMINGHAM - MUMBAI. www.it-ebooks.info. Whoops! There was a problem loading this page. Retrying... Whoops! There was a problem loading this page. Retrying... Corona SDK application design.pdf. Corona SDK application design.pdf. Open. Extract. Open w

Installing OSCARS 0.6 - GitHub
... memory recommended. • 30GB of hard disk space ... Please note these: a. RPMs do not perform any “merge” of data in case you have both 0.5 and 0.6 tables.

adobe pdf library sdk free download
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. adobe pdf ...

Installing Unity.pdf
Importing Assets..............................................................................................................................................11. Creating main menu .....................................................................

ios sdk create pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. ios sdk create ...