title: authentication error in Cloud Datalab: "ImportError: No module named gce”
body: <p>The following problem has been encountered by me and others in a variety of different GCP projects, and under circumstances where the same code worked a few days earlier.</p>
  
  <p>I am walking through all of the steps again right now, just to make sure that I still see the same thing.  I started by deleting the running instance of Cloud Datalab in my GCP project, and then I started over: first deploy Datalab, then "start using" Datalab.</p>
  
  <p>I then select a pre-existing notebook that I have which starts with the following lines:</p>
  
  <pre><code>!pip install --upgrade google-api-python-client
  from httplib2 import Http
  from oauth2client.client import GoogleCredentials
  credentials = GoogleCredentials.get_application_default()
  http = Http()
  credentials.authorize(http)
  </code></pre>
  
  <p>This has worked in the past for me and for others.  Now I get this ImportError:</p>
  
  <pre><code>---------------------------------------------------------------------------
  ImportError                               Traceback (most recent call last)
  &lt;ipython-input-2-deffc94100d1&gt; in &lt;module&gt;()
        1 from httplib2 import Http
        2 from oauth2client.client import GoogleCredentials
  ----&gt; 3 credentials = GoogleCredentials.get_application_default()
        4 http = Http()
        5 credentials.authorize(http)
  
  /usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in get_application_default()
     1202         GoogleCredentials.get_application_default().
     1203   
  -&gt; 1204         Args:
     1205             access_token: string, access token.
     1206             client_id: string, client identifier.
  
  /usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in _get_implicit_credentials(cls)
     1187     """
     1188 
  -&gt; 1189     NON_SERIALIZED_MEMBERS =  (
     1190         frozenset(['_private_key']) |
     1191         OAuth2Credentials.NON_SERIALIZED_MEMBERS)
  
  /usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in _implicit_credentials_from_gce()
     1123 
     1124 def _in_gae_environment():
  -&gt; 1125     """Detects if the code is running in the App Engine environment.
     1126 
     1127     Returns:
  
  /usr/local/lib/python2.7/dist-packages/oauth2client/client.pyc in _get_application_default_credential_GCE()
     1378         """Get the Application Default Credentials for the current environment.
     1379 
  -&gt; 1380         Raises:
     1381             ApplicationDefaultCredentialsError: raised when the credentials
     1382                                                 fail to be retrieved.
  
  ImportError: No module named gce
  </code></pre>
  
  <p>Has something changed?  has a module that was previously named "gce" been renamed?  do I need to create credentials?  (The project has both a default App Engine service account and a default Compute Engine service account, and has all of the APIs that I think might need to be enabled already enabled.)</p>
  
  <p>20-apr-2016 UPDATE: After not trying to repeat this for about a month, I was looking at this again yesterday.  The first time I tried to re-run the same notebook I was working with last month, I needed to take <em>out</em> the fix I had added in as a result of this issue in order to get it to work.  But today that same code would again not work.  In the mean-time I noticed that the recommendations had been updated, so I am now going to walk through the recommended approaches.</p>
  
  <pre><code>!pip show google-api-python-client
  ---
  Name: google-api-python-client
  Version: 1.5.0
  Location: /usr/local/lib/python2.7/dist-packages
  Requires: httplib2, uritemplate, six, oauth2client
  </code></pre>
  
  <p>Looking <a href="https://github.com/google/google-api-python-client/blob/master/setup.py" rel="nofollow">here</a>  the specific versions required seem to be: httplib2>=0.8,&lt;1; <em>any</em> oauth2client; six>=1.6.1,&lt;2; and uritemplate>=0.6,&lt;1.  (The change to allow earlier oauth2client versions seems to have been committed on Mar 14, but <a href="https://pypi.python.org/pypi/google-api-python-client/" rel="nofollow">Pypi</a> shows the most recent version as 1.5.0 uploaded on Feb 20, which agrees with the <a href="https://github.com/google/google-api-python-client/releases" rel="nofollow">Releases page</a> which says that 1.5.0 was released on Feb 19, which may have been when this problem originally appeared although I didn't notice it for a few weeks.)</p>
  
  <p>I have not been able to get much further in trying out the 3 options described by Anthonios because I repeatedly get "Connection failed" or other errors when trying to use Datalab.  I will try to update this issue again soon.</p>