【问题标题】:Installed pygraphviz on Windows 7, but unable to import it; can't find _graphviz在 Windows 7 上安装了 pygraphviz,但无法导入;找不到_graphviz
【发布时间】:2015-01-10 21:47:30
【问题描述】:

我正在尝试在我的 64 位安装的 Windows 7 SP1 上安装 pygraphviz。通过更正setup.py 文件的以下行,我能够使通常的python setup.py install 命令正常工作:

include_dirs = r"C:\Program Files (x86)\Graphviz2.38\include"
library_dirs = r"C:\Program Files (x86)\Graphviz2.38\lib\release\lib"

但是,当我尝试导入它时,我收到以下错误:

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygraphviz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pygraphviz\__init__.py", line 58, in <module>
    from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute
  File "pygraphviz\agraph.py", line 26, in <module>
    from . import graphviz as gv
  File "pygraphviz\graphviz.py", line 28, in <module>
    _graphviz = swig_import_helper()
  File "pygraphviz\graphviz.py", line 20, in swig_import_helper
    import _graphviz
ImportError: No module named _graphviz

这令人费解,因为安装 pygraphviz 的目录确实包含一个 _graphviz.pyd 文件。如果我去那个目录并尝试导入它,我会得到一个不同的 ImportError:

C:\Python27\Lib\site-packages\pygraphviz>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _graphviz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.

据我所知,_graphviz.pyd 文件似乎编译不正确(我使用的是 mingw32,已相应地编辑了我的 distutils.cfg 文件)。我无法从其他 pygraphviz 用户那里找到这个问题的任何其他实例。我做错了什么?

【问题讨论】:

    标签: python graphviz pygraphviz


    【解决方案1】:

    这是我为完美运行安装所做的。在 Windows 64 位 SP1 上使用 Anaconda 发行版运行 Python 2.7.8。

    1. here下载并安装Graphviz 2.38
    2. here 下载pygraphviz 的二进制安装程序。使用适当的版本 (pygraphviz‑1.2.win‑amd64‑py2.7.exe)。安装。确保安装程序检测到正确的 PYTHONPATH

    结果:

    【讨论】:

      猜你喜欢
      • 2011-06-02
      • 2018-04-21
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 2011-02-17
      • 2019-04-09
      • 2017-04-02
      • 1970-01-01
      相关资源
      最近更新 更多