PointASNL icon indicating copy to clipboard operation
PointASNL copied to clipboard

ImportError: No module named 'nearest_neighbors.lib'

Open Timaces opened this issue 5 years ago • 16 comments

I meeting the follow error,can you help me ?

omnisky@omnisky:~/Documents/PointASNL-master/tf_ops$ sh compile_ops.sh omnisky@omnisky:~/Documents/PointASNL-master/tf_ops$ cd ../ omnisky@omnisky:~/Documents/PointASNL-master$ python train.py --data /home/omnisky/Documents/PointASNL-master/data/modelnet40_ply_hdf5_2048 --exp_dir PointASNL_without_noise Traceback (most recent call last): File "train.py", line 57, in MODEL = importlib.import_module(FLAGS.model) # import network module File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File "", line 969, in _find_and_load File "", line 958, in _find_and_load_unlocked File "", line 673, in _load_unlocked File "", line 665, in exec_module File "", line 222, in _call_with_frames_removed File "/home/omnisky/Documents/PointASNL-master/models/pointasnl_cls.py", line 9, in from pointasnl_util import PointASNLSetAbstraction, get_repulsion_loss File "/home/omnisky/Documents/PointASNL-master/utils/pointasnl_util.py", line 19, in import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors ImportError: No module named 'nearest_neighbors.lib'

Timaces avatar Sep 07 '20 02:09 Timaces

I have a same issue

kingsj0405 avatar Sep 16 '20 07:09 kingsj0405

Hi @Timaces , this problem may caused by different cython library, please try import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors here.

yanx27 avatar Sep 26 '20 02:09 yanx27

When I change "import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors". I meet this error.

UnknownError (see above for traceback): AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch' Traceback (most recent call last):

File "/storage/home/hcoda1/5/zwang945/p-ywang93-0/tensorflow-1.13.1-env/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py", line 31, in knn_query neighbor_idx = nearest_neighbors.knn_batch(support_pts, query_pts, k, omp=True)

AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'

     [[node layer1/PyFunc (defined at /storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py:64) ]]

ZhichaoWang970201 avatar Feb 07 '21 18:02 ZhichaoWang970201

@ZhichaoWang970201 I have a same issue. Have you solve it?

January-cv avatar Feb 27 '21 06:02 January-cv

When I change "import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors". I meet this error.

UnknownError (see above for traceback): AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch' Traceback (most recent call last):

File "/storage/home/hcoda1/5/zwang945/p-ywang93-0/tensorflow-1.13.1-env/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py", line 31, in knn_query neighbor_idx = nearest_neighbors.knn_batch(support_pts, query_pts, k, omp=True)

AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'

     [[node layer1/PyFunc (defined at /storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py:64) ]]

I have the same issue, may be import utils.nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors works fine

ChanWunsam avatar Apr 12 '21 06:04 ChanWunsam

When I change "import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors". I meet this error. UnknownError (see above for traceback): AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch' Traceback (most recent call last): File "/storage/home/hcoda1/5/zwang945/p-ywang93-0/tensorflow-1.13.1-env/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args) File "/storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py", line 31, in knn_query neighbor_idx = nearest_neighbors.knn_batch(support_pts, query_pts, k, omp=True) AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'

     [[node layer1/PyFunc (defined at /storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py:64) ]]

I have the same issue, may be import utils.nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors works fine

I have tried what you said,but it doesn't work.Hava you solved this problem?

ch19971118 avatar Sep 07 '21 09:09 ch19971118

@ZhichaoWang970201 I have a same issue. Have you solve it?

hello ,have you solved this problem?

ch19971118 avatar Sep 07 '21 09:09 ch19971118

@ZhichaoWang970201 I have a same issue. Have you solve it?

hello ,have you solved this problem? I have solved this problem, and I thinks this problem dues to the error of "sh compile.sh". so you can try to run this statement and see whether exists error. if it has error, please solve them and "import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors" will be ok. if it doesn't has error, then I don't know how to solve them. good luck~

UnderTheMangoTree avatar Sep 21 '21 03:09 UnderTheMangoTree

problem, and I thinks this problem dues to the error of "sh compile.sh". so you can try to run this statement and see whether exists error. if it has error, please solve them and "import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors" will be ok. if it doesn't has error, then I don't know how to solve them. goo

Thank you for your reply:)

ch19971118 avatar Sep 21 '21 07:09 ch19971118

problem, and I thinks this problem dues to the error of "sh compile.sh". so you can try to run this statement and see whether exists error. if it has error, please solve them and "import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors" will be ok. if it doesn't has error, then I don't know how to solve them. goo

I have a familiar problem. Did you solve this problem?

Mike-6 avatar Aug 09 '22 08:08 Mike-6

When I change "import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors". I meet this error.

UnknownError (see above for traceback): AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch' Traceback (most recent call last):

File "/storage/home/hcoda1/5/zwang945/p-ywang93-0/tensorflow-1.13.1-env/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args)

File "/storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py", line 31, in knn_query neighbor_idx = nearest_neighbors.knn_batch(support_pts, query_pts, k, omp=True)

AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'

     [[node layer1/PyFunc (defined at /storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py:64) ]]

I have a familiar problem. Did you solve this problem?

Mike-6 avatar Aug 09 '22 08:08 Mike-6

When I change "import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors". I meet this error. UnknownError (see above for traceback): AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch' Traceback (most recent call last): File "/storage/home/hcoda1/5/zwang945/p-ywang93-0/tensorflow-1.13.1-env/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args) File "/storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py", line 31, in knn_query neighbor_idx = nearest_neighbors.knn_batch(support_pts, query_pts, k, omp=True) AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'

     [[node layer1/PyFunc (defined at /storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py:64) ]]

I have a familiar problem. Did you solve this problem?

I also ran into this problem, and I ended up finding out that it was caused by the unsuccessful compilation of the sh compile_op.sh. Before compiling the compile_op.sh, go to utils/cpp_wrappers/compile_wrappers.sh and change !/bin/bash to #! /bin/bash Then compile compile_op.sh, and upon success, import nearest_neighbors.lib.python. nearest_neighbors as nearest_neighbors no errors are reported

qiqi27 avatar Aug 26 '22 05:08 qiqi27

When I change "import nearest_neighbors rather than import nearest_neighbors.lib.python.nearest_neighbors as nearest_neighbors". I meet this error. UnknownError (see above for traceback): AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch' Traceback (most recent call last): File "/storage/home/hcoda1/5/zwang945/p-ywang93-0/tensorflow-1.13.1-env/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call ret = func(*args) File "/storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py", line 31, in knn_query neighbor_idx = nearest_neighbors.knn_batch(support_pts, query_pts, k, omp=True) AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'

     [[node layer1/PyFunc (defined at /storage/scratch1/5/zwang945/PointASNL-master/utils/pointasnl_util.py:64) ]]

I have a familiar problem. Did you solve this problem?

I also ran into this problem, and I ended up finding out that it was caused by the unsuccessful compilation of the sh compile_op.sh. Before compiling the compile_op.sh, go to utils/cpp_wrappers/compile_wrappers.sh and change !/bin/bash to #! /bin/bash Then compile compile_op.sh, and upon success, import nearest_neighbors.lib.python. nearest_neighbors as nearest_neighbors no errors are reported

thank you

Mike-6 avatar Aug 26 '22 08:08 Mike-6

I has sloved this problem!when i run bash compile_op.sh,it still occur error,you should to check if It generate file that neareast_neighbors.cpython-37m-x86_64-linux-gnu.so in utils/nearest_neighbors/lib/python .The file is the same as your python version

1806610292 avatar Jan 14 '23 07:01 1806610292

我已经解决了这个问题!当我运行 bash compile_op.sh 时,它仍然出现错误,你应该检查它是否在 utils/nearest_neighbors/lib/python 中生成 neareast_neighbors.cpython-37m-x86_64-linux-gnu.so 文件。该文件与您的python版本相同

这个文件我也生成了,但是仍然不行

liuyuansheng624 avatar Mar 28 '23 00:03 liuyuansheng624