该代码是由其他人使用 Python 2.7.12、networkx 1.11、numpy 1.13.0、scipy 0.18.1、matplotlib 2.0.2 编写的。它由几个自制模块组成。我已使用“2to3”转换器将整个代码转换为 Python 3.x。我正在使用具有所有最新软件包的 Spyder 运行整个代码。
现在在运行代码时AttributeError: 'DiGraph' object has no attribute '_node'
出现错误。以下是 spyder 中的错误信息。
runfile('C:/Users/NaVnEeT/Desktop/Thesis/WIP2/main.py', wdir='C:/Users/NaVnEeT/Desktop/Thesis/WIP2')
__main__ : INFO main() started
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
Settings : INFO Settings __init__ finished
TransGrph : INFO Graph is loaded from file
Traceback (most recent call last):
File "<ipython-input-1-c61da2f96623>", line 1, in <module>
runfile('C:/Users/NaVnEeT/Desktop/Thesis/WIP2/main.py', wdir='C:/Users/NaVnEeT/Desktop/Thesis/WIP2')
File "C:\Users\NaVnEeT\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "C:\Users\NaVnEeT\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/NaVnEeT/Desktop/Thesis/WIP2/main.py", line 137, in <module>
main()
File "C:/Users/NaVnEeT/Desktop/Thesis/WIP2/main.py", line 92, in main
ch8NLR()
File "C:\Users\NaVnEeT\Desktop\Thesis\WIP2\code\thesis\ch8NLR.py", line 176, in ch8NLR
graph = TransportGraph(settings[0])
File "C:\Users\NaVnEeT\Desktop\Thesis\WIP2\code\buildgraph\transportgraph.py", line 58, in __init__
self.dmatrix = add_dmatrix(self.G, settings)
File "C:\Users\NaVnEeT\Desktop\Thesis\WIP2\code\buildgraph\demandmatrix.py", line 20, in add_dmatrix
origdest_graph = [x for x in G.nodes() if x[0] == 'F']
File "C:\Users\NaVnEeT\Anaconda3\lib\site-packages\networkx\classes\graph.py", line 717, in nodes
nodes = NodeView(self)
File "C:\Users\NaVnEeT\Anaconda3\lib\site-packages\networkx\classes\reportviews.py", line 168, in __init__
self._nodes = graph._node
AttributeError: 'DiGraph' object has no attribute '_node'
如果需要解决方案,我可以提供部分代码。
注意:代码使用旧包成功运行。