Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import Node2Vec #105

Open
chuymtz opened this issue Jul 29, 2023 · 5 comments
Open

Cannot import Node2Vec #105

chuymtz opened this issue Jul 29, 2023 · 5 comments

Comments

@chuymtz
Copy link

chuymtz commented Jul 29, 2023

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.

@eliorc
Copy link
Owner

eliorc commented Jul 31, 2023

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

@chuymtz
Copy link
Author

chuymtz commented Jul 31, 2023

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?

@alisalh
Copy link

alisalh commented Nov 8, 2023

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

@eliorc
Copy link
Owner

eliorc commented Nov 8, 2023

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

@rwchakra
Copy link

rwchakra commented Apr 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants