googledatalab / datalab

Interactive tools and developer experiences for Big Data on Google Cloud Platform.
Apache License 2.0
974 stars 249 forks source link

importing apache_beam #1975

Open eilalan opened 6 years ago

eilalan commented 6 years ago

Hello,

I am running the following code with python 2 kernel:

!pip install --upgrade setuptools !pip install apache-beam !pip install apache-beam[gcp] Installation is completing successfully.

However, when i execute the following command: import apache_beam as beam I get the following error:

`ImportErrorTraceback (most recent call last)

in () ----> 1 import apache_beam as beam /usr/local/envs/py2env/lib/python2.7/site-packages/apache_beam/__init__.pyc in () 84 import apache_beam.internal.pickler 85 ---> 86 from apache_beam import coders 87 from apache_beam import io 88 from apache_beam import typehints /usr/local/envs/py2env/lib/python2.7/site-packages/apache_beam/coders/__init__.py in () 16 # 17 ---> 18 from apache_beam.coders.coders import * 19 from apache_beam.coders.typecoders import registry /usr/local/envs/py2env/lib/python2.7/site-packages/apache_beam/coders/coders.py in () 27 import google.protobuf 28 ---> 29 from apache_beam.coders import coder_impl 30 from apache_beam.portability.api import beam_runner_api_pb2 31 from apache_beam.utils import proto_utils ImportError: cannot import name coder_impl` Any idea what am I missing with the new version? I used the same code in the past and it was working. Thanks, eilalan
harmon commented 6 years ago

Maybe try:

! bash -c "source activate py2env && pip install apache-beam"

Otherwise not sure, it looks like it's in the correct directory, so unless it's an issue with the kernel (maybe kill it and restart?), should work.

eilalan commented 6 years ago

will try this and update. Thanks

ojarjur commented 6 years ago

@harmon has the right idea.

The issue is that running a bash command using the ! magic causes it to run in the default Conda environment, which is the Python 3 one.

To get libraries installed in the Python 2 Conda environment, you have to explicitly switch to it first (via source activate py2env).

eilalan commented 6 years ago

thank. I will try that. Do you know if there is a plan to have updated dataflow and apache-beam available in the future versions of datalab?