title: ContextualVersionConflict: Datalab + Cloud Vision
body: <p>I'm getting a ContextualVersionConflict when making a call to Google Cloud Vision API</p>
  
  <p>I have installed/upgraded the libraries I can think of, to no avail. The code works on my local machine, the issue just happens in Datalab. </p>
  
  <p><strong>Code:</strong> </p>
  
  <pre><code>!pip install --upgrade google-cloud-bigquery
  !pip install --upgrade google-api-python-client
  !pip install --upgrade google-api-core
  !pip install --upgrade google-cloud-vision
  
  #below from https://cloud.google.com/vision/docs/detecting-safe-search
  def detect_safe_search_uri(uri):
      """Detects unsafe features in the file located in Google Cloud Storage or
      on the Web."""
      from google.cloud import vision
      client = vision.ImageAnnotatorClient()
      image = vision.types.Image()
      image.source.image_uri = uri
  
      response = client.safe_search_detection(image=image)
      safe = response.safe_search_annotation
  
      # Names of likelihood from google.cloud.vision.enums
      likelihood_name = ('UNKNOWN', 'VERY_UNLIKELY', 'UNLIKELY', 'POSSIBLE',
                         'LIKELY', 'VERY_LIKELY')
      print('Safe search:')
  
      print('adult: {}'.format(likelihood_name[safe.adult]))
      print('medical: {}'.format(likelihood_name[safe.medical]))
      print('spoofed: {}'.format(likelihood_name[safe.spoof]))
      print('violence: {}'.format(likelihood_name[safe.violence]))
      print('racy: {}'.format(likelihood_name[safe.racy]))
  
  #Sample URI    
  detect_safe_search_uri("https://www.victoriassecret.com/p/404x539/tif/1a/d2/1ad2f0b4a7054d81ad178b941f3a8b80/395481036_OM_F.jpg")
  
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>...
  ...
  ...
  
  /usr/local/envs/py3env/lib/python3.5/site-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
      784                 # Oops, the "best" so far conflicts with a dependency
      785                 dependent_req = required_by[req]
  --&gt; 786                 raise VersionConflict(dist, req).with_context(dependent_req)
      787 
      788             # push the new requirements onto the stack
  
  ContextualVersionConflict: (google-api-core 0.1.4 (/usr/local/envs/py3env/lib/python3.5/site-packages), Requirement.parse('google-api-core[grpc]&lt;2.0.0dev,&gt;=1.6.0'), {'google-cloud-vision'})
  </code></pre>