简体   繁体   中英

SyntaxError: invalid syntax when i import avro in python3

I just want to import avro in python3. And I get error just import avro schema.

import os
import string
import sys

from avro import schema
...
# others are not matter

And I can only read

Traceback (most recent call last):
  File "/home/ktz/IdeaProjects/HadoopExample/src/main/python/chap4/writer_pairs.py", line 5, in <module>
    from avro import schema
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 896, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1139, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1115, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1096, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 444, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 533, in spec_from_file_location
  File "/usr/local/lib/python3.5/dist-packages/avro-1.8.1-py3.5.egg/avro/schema.py", line 340
    except Exception, e:
                    ^
SyntaxError: invalid syntax

Sorry for that I`m first in Python..

如果您使用的是Python3,则需要使用avro-python3而不是avro

You are using python2 version of avro code in python3. if you run the same using python2 then there won't be the error otherwise install python3 compatible avro.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM