Skip to main content
 首页 » 编程设计

python之在 Mac 上运行 sugiyama.py 时出现 lxml 错误

2024年11月01日12lhb25

最近我想在 Mac 上尝试 flow-project,在安装所有要求并尝试运行 python examples/sumo/sugiyama.py 之后,我收到如下所述的错误。你能帮我解决一下吗?

Traceback (most recent call last): 
  File "examples/sumo/sugiyama.py", line 7, in <module> 
    from flow.core.experiment import Experiment 
  File "/Users/voanhkha/Desktop/flow/flow/core/experiment.py", line 9, in <module> 
    from flow.core.util import emission_to_csv 
  File "/Users/voanhkha/Desktop/flow/flow/core/util.py", line 6, in <module> 
    from lxml import etree 
ImportError: dlopen(/Users/voanhkha/anaconda3/envs/flow/lib/python3.6/site-packages/lxml/etree.cpython-36m-darwin.so, 2): no suitable image found.  Did find: 
    /Users/voanhkha/anaconda3/envs/flow/lib/python3.6/site-packages/lxml/etree.cpython-36m-darwin.so: unknown file type, first eight bytes: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
    /Users/voanhkha/anaconda3/envs/flow/lib/python3.6/site-packages/lxml/etree.cpython-36m-darwin.so: unknown file type, first eight bytes: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 

请您参考如下方法:

我遇到了同样的问题,卸载了 lxml 的 conda 版本,然后使用 pip 重新安装。

conda uninstall lxml 
pip install lxml