Using automl_v1beta1 in DataLab

1,676 views
Skip to first unread message

richar...@candide.eu

unread,
Aug 9, 2018, 6:47:28 AM8/9/18
to cloud-vision-discuss
I'm trying to use the automl_v1beta1 in DataLab. I'm running the following code:

!pip install google-cloud-automl
from google.cloud import automl_v1beta1

But keep seeing the following error:

ContextualVersionConflict: (google-api-core 0.1.4 (/usr/local/envs/py2env/lib/python2.7/site-packages), Requirement.parse('google-api-core[grpc]<2.0.0dev,>=1.1.0'), set(['google-cloud-automl'])) 

I tried doing the following:

!pip install -U google-api-core 

But then I get the following error when importing automl_v1beta:

ImportErrorTraceback (most recent call last)
<ipython-input-3-d166b6559e4e> in <module>() 1 get_ipython().system(u'pip install -U google-api-core') 2 get_ipython().system(u'pip install google-cloud-automl') ----> 3 from google.cloud import automl_v1beta1 /usr/local/envs/py2env/lib/python2.7/site-packages/google/cloud/automl_v1beta1/__init__.py in <module>() 15 from __future__ import absolute_import 16 ---> 17 from google.cloud.automl_v1beta1 import types 18 from google.cloud.automl_v1beta1.gapic import auto_ml_client 19 from google.cloud.automl_v1beta1.gapic import enums ImportError: cannot import name types
1 get_ipython().system(u'pip install -U google-api-core')
2 get_ipython().system(u'pip install google-cloud-automl')
----> 3 from google.cloud import automl_v1beta1 /usr/local/envs/py2env/lib/python2.7/site-packages/google/cloud/automl_v1beta1/__init__.py in <module>() 15 from __future__ import absolute_import 16 ---> 17 from google.cloud.automl_v1beta1 import types 18 from google.cloud.automl_v1beta1.gapic import auto_ml_client 19 from google.cloud.automl_v1beta1.gapic import enums ImportError: cannot import name types /usr/local/envs/py2env/lib/python2.7/site-packages/google/cloud/automl_v1beta1/__init__.py in <module>() 15 from __future__ import absolute_import 16 ---> 17 from google.cloud.automl_v1beta1 import types 18 from google.cloud.automl_v1beta1.gapic import auto_ml_client 19 from google.cloud.automl_v1beta1.gapic import enums ImportError: cannot import name types
15 from __future__ import absolute_import
16
---> 17 from google.cloud.automl_v1beta1 import types 18 from google.cloud.automl_v1beta1.gapic import auto_ml_client 19 from google.cloud.automl_v1beta1.gapic import enums ImportError: cannot import name types
18 from google.cloud.automl_v1beta1.gapic import auto_ml_client
19 from google.cloud.automl_v1beta1.gapic import enums ImportError: cannot import name types

I realise this is still in beta, but I'm really keen to get this working. Any help with this would be greatly appreciated.

Cheers,
Rich.

Jinjun (Cloud Platform Support)

unread,
Aug 14, 2018, 4:11:46 PM8/14/18
to cloud-vision-discuss
Hello Rich,

Can you upgrade pip in Datalab Notebook first?

!pip install --upgrade pip

richar...@candide.eu

unread,
Aug 16, 2018, 5:17:26 AM8/16/18
to cloud-vision-discuss
Hi, thanks for your response. I tried this but still see the same error.

Jinjun (Cloud Platform Support)

unread,
Aug 16, 2018, 2:09:02 PM8/16/18
to cloud-vision-discuss
How about just run !pip install google-cloud-automl like in this documentation [1]?

When I tried this, it automatically uninstalled google-api-core-0.1.4, then installed google-api-core-1.3.0 and google-cloud-automl-0.1.1.


richar...@candide.eu

unread,
Aug 20, 2018, 8:52:15 AM8/20/18
to cloud-vision-discuss
The solution to this problem is as follows:

Remove all `gapic-google-cloud-{api-name}-{api-version}` and `proto-google-cloud-{api-name}-{api-version}` that are currently installed, and install `google-cloud-{api-name}` instead.

In my case this was:

!pip uninstall -y gapic-google-cloud-datastore-v1
!pip uninstall -y gapic-google-cloud-error-reporting-v1beta1
!pip uninstall -y gapic-google-cloud-logging-v2
!pip uninstall -y proto-google-cloud-datastore-v1
!pip uninstall -y proto-google-cloud-error-reporting-v1beta1
!pip uninstall -y proto-google-cloud-logging-v2

!pip install google-cloud-error-reporting
!pip install google-cloud-logging
!pip install google-cloud-datastore

Pichai Ongvasith

unread,
Oct 4, 2018, 7:07:57 AM10/4/18
to cloud-vision-discuss
Hi,

Having the same problem, but your code above doesn't work for me.
Datalab Version: 1.2.20180818
I `pip list`  and didn't find any gapic-xx or proto-xx package. Any suggestion?

thanks.

Ethan Bao

unread,
Oct 4, 2018, 12:24:00 PM10/4/18
to pic...@gmail.com, cloud-visi...@googlegroups.com
Hi Pichai,
Can you do `pip freeze | grep google-cloud-`, can paste the result?

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Vision Discussion Google Group (cloud-visi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Vision community and the Google Cloud Vision Team.
---
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.
To post to this group, send email to cloud-visi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/bf276869-4c6f-4926-b7e5-7f616070a6fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pichai Ongvasith

unread,
Oct 5, 2018, 4:06:20 AM10/5/18
to cloud-vision-discuss
Hi Ethan,

here's the result.

google-cloud-bigquery==0.23.0
google-cloud-core==0.28.1
google-cloud-dataflow==2.0.0
google-cloud-monitoring==0.28.0
proto-google-cloud-datastore-v1==0.90.0

so the culprit would be the last line?

thanks,
pichai
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages