PacktPublishing / Graph-Machine-Learning

Graph Machine Learning, published by Packt
MIT License
261 stars 140 forks source link

Chapter 3 numpy issues with gensim #6

Closed scottlittle closed 2 years ago

scottlittle commented 2 years ago

I had an issue with numpy and gensim for chapter 3 (first chapter that I ran examples). This was the error specifically:

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

My solution was to use a conda environment. I set up an environment.yml file as below

name: packt_graphml_env
channels:
   - conda-forge
   - defaults
dependencies:
   - python==3.8.*
   - pip
   - ipykernel
   - pandas
   - gensim==3.8.3
   - numpy==1.19.5
   - networkx==2.5.*
   - matplotlib==3.2.*
   - node2vec==0.3.*
   - karateclub==1.0.*
   - scipy==1.6.*
   - tensorflow==2.4.1
   - scikit-learn==0.24.*
   - stellargraph::stellargraph
   - pip:
     #- "--editable=git+https://github.com/stellargraph/stellargraph.git#egg=stellargraph"
     - "--editable=git+https://github.com/palash1992/GEM.git#egg=GEM"

and install/update with: mamba env update -f environment.yml

Of course, replace mamba with conda if you don't have mamba. And I added ipykernel for a Jupyter kernel, which was already installed in my base conda environment.

Hope this helps someone.