benedekrozemberczki / karateclub

Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020)

Home Page:https://karateclub.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

from karateclub import FeatherGraph error

johnnytam100 opened this issue · comments

Hi I am trying to import FeatherGraph in colab but met this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-6-ec16dd5c53cc>](https://localhost:8080/#) in <module>
----> 1 from karateclub import FeatherGraph

9 frames
/usr/local/lib/python3.8/dist-packages/gensim/_matutils.pyx in init gensim._matutils()

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Any idea how to deal with it? Thanks!

Can you provide the full traceback?

I'm sorry!

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-7-ec16dd5c53cc>](https://localhost:8080/#) in <module>
----> 1 from karateclub import FeatherGraph

9 frames
[/usr/local/lib/python3.8/dist-packages/karateclub/__init__.py](https://localhost:8080/#) in <module>
      1 from karateclub.community_detection import *
----> 2 from karateclub.node_embedding import *
      3 from karateclub.graph_embedding import *
      4 from karateclub.utils import *
      5 from karateclub.dataset import *

[/usr/local/lib/python3.8/dist-packages/karateclub/node_embedding/__init__.py](https://localhost:8080/#) in <module>
----> 1 from .neighbourhood import *
      2 from .structural import *
      3 from .attributed import *
      4 from .meta import *

[/usr/local/lib/python3.8/dist-packages/karateclub/node_embedding/neighbourhood/__init__.py](https://localhost:8080/#) in <module>
      1 from .grarep import GraRep
----> 2 from .deepwalk import DeepWalk
      3 from .node2vec import Node2Vec
      4 from .walklets import Walklets
      5 from .nmfadmm import NMFADMM

[/usr/local/lib/python3.8/dist-packages/karateclub/node_embedding/neighbourhood/deepwalk.py](https://localhost:8080/#) in <module>
      1 import numpy as np
      2 import networkx as nx
----> 3 from gensim.models.word2vec import Word2Vec
      4 from karateclub.utils.walker import RandomWalker
      5 from karateclub.estimator import Estimator

[/usr/local/lib/python3.8/dist-packages/gensim/__init__.py](https://localhost:8080/#) in <module>
      9 import logging
     10 
---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
     12 
     13 

[/usr/local/lib/python3.8/dist-packages/gensim/corpora/__init__.py](https://localhost:8080/#) in <module>
      4 
      5 # bring corpus classes directly into package namespace, to save some typing
----> 6 from .indexedcorpus import IndexedCorpus  # noqa:F401 must appear before the other classes
      7 
      8 from .mmcorpus import MmCorpus  # noqa:F401

[/usr/local/lib/python3.8/dist-packages/gensim/corpora/indexedcorpus.py](https://localhost:8080/#) in <module>
     12 import numpy
     13 
---> 14 from gensim import interfaces, utils
     15 
     16 logger = logging.getLogger(__name__)

[/usr/local/lib/python3.8/dist-packages/gensim/interfaces.py](https://localhost:8080/#) in <module>
     17 import logging
     18 
---> 19 from gensim import utils, matutils
     20 
     21 

[/usr/local/lib/python3.8/dist-packages/gensim/matutils.py](https://localhost:8080/#) in <module>
   1028 try:
   1029     # try to load fast, cythonized code if possible
-> 1030     from gensim._matutils import logsumexp, mean_absolute_difference, dirichlet_expectation
   1031 
   1032 except ImportError:

/usr/local/lib/python3.8/dist-packages/gensim/_matutils.pyx in init gensim._matutils()

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

These are gensim and NumPy shenanigans, and unrelated to the Karate Club package. The only thing we could reasonably do is to wrap them in a try except. Have you already tried to update it and NumPy, such as by running pip install gensim numpy -U?

Thanks for the quick response! I think it's environment issue now. Let's close this first.

Please do let me know whether the solution I proposed works, as I could add a better exception than the current one providing a more insightful message to the user with also the mentioned solution and this issue.