node2vec icon indicating copy to clipboard operation
node2vec copied to clipboard

Cannot import Node2Vec

Open chuymtz opened this issue 2 years ago • 5 comments

Hello,

From running

from node2vec import Node2Vec

I get an import error. It seems that it tries to run the script nx_pylab.py.

UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  node_collection = ax.scatter(
Node2Vec accuracy = 95.45%
Node2Vec accuracy = 72.73%

When i go to this cript i see its under the networkx pkg/drawing/ directory and the problem line is

node_collection = ax.scatter(
        xy[:, 0],
        xy[:, 1],
        s=node_size,
        c=node_color,
        marker=node_shape,
        cmap=cmap,
        vmin=vmin,
        vmax=vmax,
        alpha=alpha,
        linewidths=linewidths,
        edgecolors=edgecolors,
        label=label,
    )

I've attempted this on both python 3.8 and 3.10. This is windows.

chuymtz avatar Jul 29 '23 15:07 chuymtz

Hi, can you show me the output of pip freeze for the environment you are using?

eliorc avatar Jul 31 '23 11:07 eliorc

Of course. Thanks, This is what I'm using for py3.10.5

asttokens==2.2.1
backcall==0.2.0
colorama==0.4.6
comm==0.1.3
contourpy==1.1.0
cycler==0.11.0
debugpy==1.6.7
decorator==5.1.1
executing==1.2.0
filelock==3.12.2
fonttools==4.41.0
gensim==4.3.1
ipykernel==6.24.0
ipython==8.14.0
jedi==0.18.2
Jinja2==3.1.2
joblib==1.3.1
jupyter_client==8.3.0
jupyter_core==5.3.1
kiwisolver==1.4.4
MarkupSafe==2.1.3
matplotlib==3.7.2
matplotlib-inline==0.1.6
mpmath==1.3.0
nest-asyncio==1.5.6
networkx==2.8.8
node2vec==0.4.6
numpy==1.25.1
packaging==23.1
pandas==2.0.3
parso==0.8.3
pickleshare==0.7.5
Pillow==10.0.0
platformdirs==3.9.1
prompt-toolkit==3.0.39
psutil==5.9.5
pure-eval==0.2.2
Pygments==2.15.1
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2023.3
pywin32==306
pyzmq==25.1.0
scikit-learn==1.3.0
scipy==1.11.1
six==1.16.0
smart-open==6.3.0
stack-data==0.6.2
sympy==1.12
threadpoolctl==3.2.0
torch==2.0.1
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
typing_extensions==4.7.1
tzdata==2023.3
wcwidth==0.2.6

Seems to me it's more about the matplotlib than anything. Perhaps an issue with my networkx version?

chuymtz avatar Jul 31 '23 18:07 chuymtz

You should use from node2vec.node2vec import Node2Vec because Node2Vec in the file node2vec.py

alisalh avatar Nov 08 '23 07:11 alisalh

You should use from node2vec.node2vec import Node2Vec because Node2Vec in the file node2vec.py

That is actually not true, because in node2vec/__init__.py I excplicitly import Node2Vec so it should be available...

I hadn't had time to debug this as I don't have enough time for this project... sorry

eliorc avatar Nov 08 '23 08:11 eliorc

Hi chuymtz, make sure your script isn't named node2vec.py. This could lead to circular imports. See here: https://stackoverflow.com/questions/75164545/inporterror-cannot-import-node2vec

rwchakra avatar Apr 03 '24 15:04 rwchakra