Python程序无法导入点分析器

Python程序无法导入点分析器,python,numpy,graphviz,pydot,Python,Numpy,Graphviz,Pydot,我正在尝试从命令行运行一个模拟python软件的大型演进。该软件依赖于以下python软件包: 1-networkX 2-py解析 3-numpy 4-pydot 5-matplotlib 6-graphviz 我得到的错误是: Couldn't import dot_parser, loading of dot files will not be possible. initializing with file= initAdapt.py in model dir= ./Test_adapta

我正在尝试从命令行运行一个模拟python软件的大型演进。该软件依赖于以下python软件包:

1-networkX

2-py解析

3-numpy

4-pydot

5-matplotlib

6-graphviz

我得到的错误是:

Couldn't import dot_parser, loading of dot files will not be possible.
initializing with file= initAdapt.py in model dir= ./Test_adaptation//
Traceback (most recent call last):
  File "run_evolution.py", line 230, in <module>
    gr.write_dot( os.path.join(test_output_dir, 'test_net.dot') )
  File "/Library/Python/2.7/site-packages/pydot.py", line 1602, in <lambda>
    lambda path, f=frmt, prog=self.prog : self.write(path, format=f,          prog=prog))
  File "/Library/Python/2.7/site-packages/pydot.py", line 1696, in write
    dot_fd.write(self.create(prog, format))
  File "/Library/Python/2.7/site-packages/pydot.py", line 1740, in create
    self.write(tmp_name)
  File "/Library/Python/2.7/site-packages/pydot.py", line 1694, in write
    dot_fd.write(self.to_string())
  File "/Library/Python/2.7/site-packages/pydot.py", line 1452, in to_string
    graph.append( node.to_string()+'\n' )
  File "/Library/Python/2.7/site-packages/pydot.py", line 722, in to_string
    node_attr.append( attr + '=' + quote_if_necessary(value) )
TypeError: cannot concatenate 'str' and 'int' objects
无法导入dot_解析器,无法加载dot文件。
使用model dir=./Test\u adaption中的file=initAdapt.py初始化//
回溯(最近一次呼叫最后一次):
文件“run_evolution.py”,第230行,在
gr.write\U dot(os.path.join(test\u output\u dir,'test\u net.dot'))
文件“/Library/Python/2.7/site packages/pydot.py”,第1602行,在
lambda路径,f=frmt,prog=self.prog:self.write(路径,格式=f,prog=prog))
文件“/Library/Python/2.7/site packages/pydot.py”,第1696行,以书面形式
dot_fd.write(自创建(程序,格式))
文件“/Library/Python/2.7/site packages/pydot.py”,第1740行,在create中
self.write(tmp_名称)
写入文件“/Library/Python/2.7/site packages/pydot.py”,第1694行
dot\u fd.write(self.to\u string())
文件“/Library/Python/2.7/site packages/pydot.py”,第1452行,to_字符串
graph.append(node.to_string()+'\n')
文件“/Library/Python/2.7/site packages/pydot.py”,第722行,to_字符串
节点属性追加(attr+'='+引号(如果需要)(值))
TypeError:无法连接'str'和'int'对象
我已经尝试过为类似的堆栈溢出建议的解决方案。我仍然会犯同样的错误。下面是我正在使用的包版本和我的python版本

  • 我正在使用python 2.7.6
  • 键入命令
    which-a python
    将产生结果:“/usr/bin/python”
1-1(1.5.7)

2-pydot(1.0.2)

3-matplotlib(1.3.1)

4-graphviz(0.4.2)

5-networkx(0.37)

6-numpy(1.8.0rc1)


有什么想法吗?鉴于类似问题的解决方案对我不起作用,我认为在我的情况下,这个问题可能更为根本。我安装python的方式可能有问题

您不使用最新版本的pydot有什么特殊原因吗

1.0.2的这一版本看起来正好解决了这个问题:


请参阅第722行。

升级我的pyparsing模块修复了此问题。尝试:

pip install --upgrade pyparsing

版本1.0.28修复了该问题。谢谢当我运行我的程序时,仍然会收到消息“无法导入dot_解析器,无法加载dot文件”。是的,错误仍然来自1.0.28的pydot。我修改了pydot.py,删除了执行“导入dot_解析器”的行,一切都很好。