ysig / GraKeL

A scikit-learn compatible library for graph kernels
https://ysig.github.io/GraKeL/
Other
588 stars 96 forks source link

How to deal this?Thx ImportError: cannot import name 'k_to_ij_triangular' from 'grakel.kernels._c_functions' #22

Closed DEEMOALICE closed 3 years ago

DEEMOALICE commented 4 years ago

Traceback (most recent call last): File "D:\python\test\GraKeL-develop\test.py", line 9, in from grakel import GraphKernel File "D:\python\test\GraKeL-develop\grakel__init.py", line 6, in from grakel.graph_kernels import GraphKernel File "D:\python\test\GraKeL-develop\grakel\graph_kernels.py", line 13, in from grakel.kernels import GraphletSampling File "D:\python\test\GraKeL-develop\grakel\kernels\init__.py", line 4, in from grakel.kernels.kernel import Kernel File "D:\python\test\GraKeL-develop\grakel\kernels\kernel.py", line 17, in from grakel.kernels._c_functions import k_to_ij_triangular ImportError: cannot import name 'k_to_ij_triangular' from 'grakel.kernels._c_functions' (unknown location) [Finished in 1.2s with exit code 1]

I just installed grakel according to the tutorial on github and ran the test. The above BUG appeared, and the package could not be installed.

ysig commented 4 years ago

Hi,

Our package uses cython extensions that need to be built for a local import (as python setup.py build_ext). As I understand from your 'fs' directory separators you use Windows. Detailed instructions of how to build your own source code in Windows will be updated in some days for now so stay tuned, in case you want to build it yourself.

If not install one of the pre-build packages using pip install grakel-dev. In this case please go outside of the directory you are in somewhere where grakel cannot be referenced locally and run your script. This should work.

Thanks a lot for your feedback.

Στις Τρί, 24 Δεκ 2019 στις 4:30 π.μ., ο/η DEEMOALICE < notifications@github.com> έγραψε:

Traceback (most recent call last): File "D:\python\test\GraKeL-develop\test.py", line 9, in from grakel import GraphKernel File "D:\python\test\GraKeL-develop\grakelinit.py", line 6, in from grakel.graph_kernels import GraphKernel File "D:\python\test\GraKeL-develop\grakel\graphkernels.py", line 13, in from grakel.kernels import GraphletSampling File "D:\python\test\GraKeL-develop\grakel\kernelsinit_.py", line 4, in from grakel.kernels.kernel import Kernel File "D:\python\test\GraKeL-develop\grakel\kernels\kernel.py", line 17, in from grakel.kernels._c_functions import k_to_ij_triangular ImportError: cannot import name 'k_to_ij_triangular' from 'grakel.kernels._c_functions' (unknown location) [Finished in 1.2s with exit code 1]

I just installed grakel according to the tutorial on github and ran the test. The above BUG appeared, and the package could not be installed.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ysig/GraKeL/issues/22?email_source=notifications&email_token=AGY7H2LRV2CDZCZ4HO5M443Q2FX5PA5CNFSM4J6Z3QQKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ICNWWCQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGY7H2ISBFW2UMXW6RBPY5DQ2FX5PANCNFSM4J6Z3QQA .

ysig commented 4 years ago

Please see: https://ysig.github.io/GraKeL/0.1a7/documentation/installation.html#building-grakel

kprojiang commented 4 years ago

Please see: https://ysig.github.io/GraKeL/0.1a7/documentation/installation.html#building-grakel

I have tried out the installing command, which are:

  1. conda create -n GraKeL python=3.6
  2. pip install grakel --verbose
  3. pip install sphinx sphinxcontrib-bibtex numpydoc sphinx-rtd-theme sphinx-gallery

The third line is to compile offline doc.

BuShiFeiGuo commented 4 years ago

Traceback (most recent call last): File "D:/04.CEcode/GraKeL-master/examples/weisfeiler_lehman_subtree.py", line 17, in from grakel.datasets import fetch_dataset File "D:\04.CEcode\GraKeL-master\grakel__init.py", line 6, in from grakel.graph_kernels import GraphKernel File "D:\04.CEcode\GraKeL-master\grakel\graph_kernels.py", line 13, in from grakel.kernels import GraphletSampling File "D:\04.CEcode\GraKeL-master\grakel\kernels\init__.py", line 4, in from grakel.kernels.kernel import Kernel File "D:\04.CEcode\GraKeL-master\grakel\kernels\kernel.py", line 17, in from grakel.kernels._c_functions import k_to_ij_triangular ImportError: cannot import name 'k_to_ij_triangular'

This problem appeared for me.. I already install Windows Virtual Studio SDK and execute python setup.py install, but these reminder as follows when execute python install.py build_ext: (py3) D:\04.CEcode\GraKeL-master>python setup.py build_ext running build_ext skipping './grakel/kernels/_isomorphism\bliss.cpp' Cython extension (up-to-date) skipping './grakel/kernels/_c_functions\functions.cpp' Cython extension (up-to-date)

xtyi1997 commented 3 years ago

pip install grakel-dev

hello,my envirement is ubuntu 16.04 python 3.6 I want use your program by pycharm but it does not work ,I want debug it , thank you.

Traceback (most recent call last): File "/home/wjc/Desktop/yxt/GraKeL-master/examples/shortest_path.py", line 17, in from grakel.datasets import fetch_dataset File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/init.py", line 6, in from grakel.graph_kernels import GraphKernel File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/graph_kernels.py", line 13, in from grakel.kernels import GraphletSampling File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/kernels/init.py", line 4, in from grakel.kernels.kernel import Kernel File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/kernels/kernel.py", line 17, in from grakel.kernels._c_functions import k_to_ij_triangular ImportError: cannot import name 'k_to_ij_triangular'

xtyi1997 commented 3 years ago

pip install grakel-dev

hello,my envirement is ubuntu 16.04 python 3.6 I want use your program by pycharm but it does not work ,I want debug it , thank you.

Traceback (most recent call last): File "/home/wjc/Desktop/yxt/GraKeL-master/examples/shortest_path.py", line 17, in from grakel.datasets import fetch_dataset File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/init.py", line 6, in from grakel.graph_kernels import GraphKernel File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/graph_kernels.py", line 13, in from grakel.kernels import GraphletSampling File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/kernels/init.py", line 4, in from grakel.kernels.kernel import Kernel File "/home/wjc/Desktop/yxt/GraKeL-master/grakel/kernels/kernel.py", line 17, in from grakel.kernels._c_functions import k_to_ij_triangular ImportError: cannot import name 'k_to_ij_triangular'

it need conda create -n env_name python=3.6 and refer https://ysig.github.io/GraKeL/0.1a7/documentation/installation.html#building-grakel

ysig commented 3 years ago

Can you try pip install grakel instead?

YoungC2015 commented 3 years ago

I met this issue today. Finally, it turned out to be a really stupid mistake: leave the directory where the setup.py was!

cshjin commented 2 years ago

I got the exact same problem. I did follow the instructions to build the ext: https://ysig.github.io/GraKeL/0.1a8/documentation/installation.html#building-grakel

The problem is building the _c_functions has no submodule, only a single _c_functions.cpython.***.so are generated. While _isomorphism has bliss and intpybliss.

Therefore I changed the import to be from grakel.kernels import _c_functions and use the function as _c_functions.k_to_ij_triangular(...)

Probably need to restructure the _c_functions the similar as _isomorphism

ysig commented 2 years ago

Hey cshjin.

Normally if you install grakel as a package you won't encounter this issue as it is prebuilt. So there are likely two reasons for this to be happening:

  1. Either you use a recent version of python like 3.9 for which we don't have built packages yet.
  2. You want to change sth in the library itself.

Can you describe:

  1. your environment (linux, windows, osx) and python version (python --version) and
  2. Your use case?

Thanks

cshjin commented 2 years ago

@ysig I am using python 3.7.10 and ubuntu 20.04 with GCC ver 9.3

I just run the examples and tutorials and see the problems there.

ysig commented 2 years ago

Can you try:

pip install https://files.pythonhosted.org/packages/6b/b9/1c30ffc28bbf995408cadd33ede4a6bf64bfbfa86d90c1a3ab7e0b699fda/grakel-0.1.8-cp37-cp37m-manylinux1_x86_64.whl

or

pip install https://files.pythonhosted.org/packages/36/c0/89ad5326d4a75f5abe9a6a7a7d28988e5b51692d9902239f56e43c296ae0/grakel-0.1.8-cp37-cp37m-manylinux2010_x86_64.whl

as located here: https://pypi.org/project/grakel/#modal-close

cshjin commented 2 years ago

It works with the installation from pip install ***-manylinux1_x86_64.whl

Thanks.