我无法使用tf_upgrade_v2脚本将任何Tensorflow项目转换为TF2.0。我在pasta
模块上遇到了问题。应该使用哪个面食版本以及解决方法是什么?
我已经安装了Tensorflow(pip3 install tensorflow==2.0.0-alpha0
),并尝试使用tf_upgrade_v2 --intree my_project --outtree my_project_upgrade
升级我的项目。失败并显示以下错误:
NFO line 46:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 49:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 30:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 33:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 21:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 24:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 21:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 24:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 35:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 38:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 68:17: Added keywords to args of function 'tf.convert_to_tensor'
INFO line 69:17: Added keywords to args of function 'tf.convert_to_tensor'
INFO line 72:34: Renamed 'tf.log' to 'tf.math.log'
INFO line 75:21: Added keywords to args of function 'tf.reduce_max'
INFO line 76:15: Added keywords to args of function 'tf.reduce_mean'
INFO line 56:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 59:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 75:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 78:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 41:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 43:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 65:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 67:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 41:13: Renamed 'tf.ConfigProto' to 'tf.compat.v1.ConfigProto'
INFO line 43:11: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 45:22: Renamed 'tf.Summary' to 'tf.compat.v1.Summary'
INFO line 84:22: Renamed 'tf.Summary' to 'tf.compat.v1.Summary'
Traceback (most recent call last):
File "/usr/local/bin/tf_upgrade_v2", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/tf_upgrade_v2_main.py", line 123, in main
args.input_tree, output_tree, args.copy_other_files)
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 624, in process_tree
_, l_report, l_errors = self.process_file(input_path, output_path)
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 494, in process_file
temp_file)
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 548, in process_opened_file
self.update_string_pasta("".join(lines), in_filename))
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 510, in update_string_pasta
t = pasta.parse(text)
File "/usr/local/lib/python3.7/site-packages/pasta/__init__.py", line 25, in parse
annotator.visit(t)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 47, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 220, in visit_Module
self.generic_visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 270, in generic_visit
self.visit(item)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 95, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 381, in visit_ClassDef
self.visit(stmt)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 95, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 411, in visit_FunctionDef
self.visit(stmt)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 47, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 530, in visit_Assign
self.visit(node.value)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 47, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 829, in visit_IfExp
self.visit(node.body)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 47, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 700, in visit_BoolOp
self.visit(value)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1190, in visit
super(AstAnnotator, self).visit(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 132, in visit
super(BaseVisitor, self).visit(node)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 262, in visit
return visitor(node)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 47, in wrapped
f(self, node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 803, in visit_Dict
self.visit(key)
File "/usr/local/lib/python3.7/site-packages/pasta/base/annotate.py", line 1188, in visit
fmt.set(node, 'indent', self._indent)
File "/usr/local/lib/python3.7/site-packages/pasta/base/formatting.py", line 37, in set
_formatting_dict(node)[name] = value
File "/usr/local/lib/python3.7/site-packages/pasta/base/formatting.py", line 49, in _formatting_dict
return getattr(node, PASTA_DICT)
AttributeError: 'NoneType' object has no attribute '__pasta__'
我尝试使用pip3 install --upgrade pasta
更新/安装面食。之后,我得到以下错误:
Traceback (most recent call last):
File "/usr/local/bin/tf_upgrade_v2", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/tf_upgrade_v2_main.py", line 123, in main
args.input_tree, output_tree, args.copy_other_files)
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 624, in process_tree
_, l_report, l_errors = self.process_file(input_path, output_path)
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 494, in process_file
temp_file)
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 548, in process_opened_file
self.update_string_pasta("".join(lines), in_filename))
File "/usr/local/lib/python3.7/site-packages/tensorflow/tools/compatibility/ast_edits.py", line 510, in update_string_pasta
t = pasta.parse(text)
AttributeError: module 'pasta' has no attribute 'parse'