我只想在python3中导入avro。我只是导入avro架构时出错。
import os
import string
import sys
from avro import schema
...
# others are not matter
我只能阅读
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
对不起,我是第一个用Python ...
答案 0 :(得分:18)
答案 1 :(得分:4)
您在python3中使用python2版本的avro代码。如果你使用python2运行相同的话,那么就不会出错,否则安装python3兼容的avro。