导入igraph时出错:ImportError:无法导入名称community_to_membership

问题描述 投票:2回答:1

我不确定这是否已被回答,但我找不到任何与我的错误有关的内容,所以我想我会发一个问题。

我在Linux上运行,我使用pip install python-igraph下载了igraph包,并确保它是由Tamas Nepusz提供的python-igraph-0.7.1包。

当我尝试做import igraph时,我收到以下错误:

~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lashen/.local/lib/python2.7/site-packages/igraph/__init__.py", line 34, in <module>
    from igraph._igraph import *
  File "/home/lashen/.local/lib/python2.7/site-packages/igraph/igraph/__init__.py", line 37, in <module>
    from igraph.cut import *
  File "/home/lashen/.local/lib/python2.7/site-packages/igraph/cut.py", line 5, in <module>
    from igraph.clustering import VertexClustering
  File "/home/lashen/.local/lib/python2.7/site-packages/igraph/igraph/clustering.py", line 32, in <module>
    from igraph import community_to_membership
ImportError: cannot import name community_to_membership

我不知道如何修复此导入错误。我是否错误地安装了igraph?好像我得到了正确的包裹......

~$ pip show python-igraph
Name: python-igraph
Version: 0.7.1.post6
Summary: High performance graph data structures and algorithms
Home-page: http://pypi.python.org/pypi/python-igraph
Author: Tamas Nepusz
Author-email: [email protected]
License: GNU General Public License (GPL)
Location: /home/lashen/.local/lib/python2.7/site-packages
Requires:

我已经尝试导入igraph的单个子模块,但无济于事。所有子模块导入(例如import igraph.cutimport igraph._igraph)都会导致相同的错误。

为什么会出现此导入错误?感谢任何帮助,谢谢!

python python-2.7 python-import igraph
1个回答
0
投票

您需要先安装sudo apt-get install libigraph0-dev,然后才能通过pip install python-igraph --user安装igraph

© www.soinside.com 2019 - 2024. All rights reserved.