tensorflow-recorder
tensorflow-recorder copied to clipboard
ImportError: cannot import name 'Parse' from 'avro.schema'
I installed tensorflow-recorder using the command: pip install tfrecorder. The package installs without any error, however, I am getting the following error when trying to import the package.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-63673124a3e9> in <module>
4 import pandas as pd
5
----> 6 import tfrecorder
7 import tensorflow as tf
~\Anaconda3\envs\tfrecords\lib\site-packages\tfrecorder\__init__.py in <module>
17 """Imports."""
18
---> 19 from tfrecorder import accessor
20 from tfrecorder.converter import convert
21 from tfrecorder.dataset_loader import load
~\Anaconda3\envs\tfrecords\lib\site-packages\tfrecorder\accessor.py in <module>
26 from IPython.core import display
27
---> 28 from tfrecorder import converter
29 from tfrecorder import constants
30 from tfrecorder import input_schema
~\Anaconda3\envs\tfrecords\lib\site-packages\tfrecorder\converter.py in <module>
25 from typing import Any, Dict, Optional, Sequence, Tuple, Union
26
---> 27 import apache_beam as beam
28 import pandas as pd
29 import tensorflow as tf
~\Anaconda3\envs\tfrecords\lib\site-packages\apache_beam\__init__.py in <module>
94
95 from apache_beam import coders
---> 96 from apache_beam import io
97 from apache_beam import typehints
98 from apache_beam import version
~\Anaconda3\envs\tfrecords\lib\site-packages\apache_beam\io\__init__.py in <module>
21 from __future__ import absolute_import
22
---> 23 from apache_beam.io.avroio import *
24 from apache_beam.io.filebasedsink import *
25 from apache_beam.io.iobase import Read
~\Anaconda3\envs\tfrecords\lib\site-packages\apache_beam\io\avroio.py in <module>
56 from avro import io as avroio
57 from avro import datafile
---> 58 from avro.schema import Parse
59 from fastavro.read import block_reader
60 from fastavro.write import Writer
ImportError: cannot import name 'Parse' from 'avro.schema' (C:\Users\xxxxx\Anaconda3\envs\tfrecords\lib\site-packages\avro\schema.py)
Solutions Tried:
- Tried installing
tensorflow-recorderthroughpip3after learning it might be python2/python3 issue from here. - Tried removing
avroto enforce this package to useavro-python3but looks like it needs avro.
Can somebody please help me with this?
Hi there, looks like there might be an issue with the downstream Avro dependency. Let me try to recreate.
On Tue, Jan 19, 2021 at 4:59 PM Milan Jain [email protected] wrote:
I installed tensorflow-recorder using the command: pip install tfrecorder. The package installs without any error, however, I am getting the following error when trying to import the package.
ImportError Traceback (most recent call last)
in 4 import pandas as pd 5 ----> 6 import tfrecorder 7 import tensorflow as tf ~\Anaconda3\envs\tfrecords\lib\site-packages\tfrecorder_init_.py in
17 """Imports.""" 18 ---> 19 from tfrecorder import accessor 20 from tfrecorder.converter import convert 21 from tfrecorder.dataset_loader import load ~\Anaconda3\envs\tfrecords\lib\site-packages\tfrecorder\accessor.py in
26 from IPython.core import display 27 ---> 28 from tfrecorder import converter 29 from tfrecorder import constants 30 from tfrecorder import input_schema ~\Anaconda3\envs\tfrecords\lib\site-packages\tfrecorder\converter.py in
25 from typing import Any, Dict, Optional, Sequence, Tuple, Union 26 ---> 27 import apache_beam as beam 28 import pandas as pd 29 import tensorflow as tf ~\Anaconda3\envs\tfrecords\lib\site-packages\apache_beam_init_.py in
94 95 from apache_beam import coders ---> 96 from apache_beam import io 97 from apache_beam import typehints 98 from apache_beam import version ~\Anaconda3\envs\tfrecords\lib\site-packages\apache_beam\io_init_.py in
21 from future import absolute_import 22 ---> 23 from apache_beam.io.avroio import * 24 from apache_beam.io.filebasedsink import * 25 from apache_beam.io.iobase import Read ~\Anaconda3\envs\tfrecords\lib\site-packages\apache_beam\io\avroio.py in
56 from avro import io as avroio 57 from avro import datafile ---> 58 from avro.schema import Parse 59 from fastavro.read import block_reader 60 from fastavro.write import Writer ImportError: cannot import name 'Parse' from 'avro.schema' (C:\Users\xxxxx\Anaconda3\envs\tfrecords\lib\site-packages\avro\schema.py)
Solutions Tried:
- Tried installing tensorflow-recorder through pip3 after learning it might be python2/python3 issue from here https://stackoverflow.com/questions/40732419/how-to-read-avro-files-in-python-3-5-2 .
- Tried removing avro to enforce this package to use avro-python3 but looks like it needs avro.
Can somebody please help me with this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/tensorflow-recorder/issues/62, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5N3Y6JOVQJ6L7SJOSXBTDS2YFENANCNFSM4WJVH4KQ .
@mbernico: were you able to replicate the issue?
Yes I was. I don't have a solution yet though. It appears that something in avro is broken, which is a dependency of dataflow, downstream of us, so we don't control the versioning. When I get a free moment I can try to figure out what's happened in the avro code base. Thanks for your patience.
On Fri, Jan 22, 2021 at 1:56 PM Milan Jain [email protected] wrote:
@mbernico https://github.com/mbernico: were you able to replicate the issue?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/tensorflow-recorder/issues/62#issuecomment-765649878, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5N3Y6G7FSARTFNNAD4G4DS3HKAFANCNFSM4WJVH4KQ .
avro.schema.Parse is a deprecated function in avro-python3: https://github.com/apache/avro/blob/72b06153729b1a7963012b1e3e0cc3837e452322/lang/py3/avro/schema.py#L1247-L1252
Both the avro library and avro-python3 now have the lowercase parse() that should be used.