解决windows平台下cpp_neighbors/cpp_subsampling报错Module not found问题

一、安装步骤

  1. https://github.com/HuguesTHOMAS/KPConv-PyTorch/tree/master/cpp_wrappers​​​​​​ 下载cpp_wrappers文件夹
  2. 然后分别将cpp_neighbors和cpp_subsampling文件夹中的setup.py文件内容替换如下:

由于numpy版本不匹配的问题,原先的setup.py文件会报错

# cpp_neighbors
from setuptools import setup, Extension
import numpy as np

# Adding sources of the project
SOURCES = [
    "../cpp_utils/cloud/cloud.cpp",
    "neighbors/neighbors.cpp",
    "wrapper.cpp"
]

# Define the extension module
module = Extension(
    name="radius_neighbors",
    sources=SOURCES,
    extra_compile_args=['/std:c++11', '-D_GLIBCXX_USE_CXX11_ABI=0'], 
    include_dirs=[np.get_include()]  
)

# Run setup
setup(ext_modules=[module])
# cpp_subsampling
from setuptools import setup, Extension
import numpy as np

# Adding sources of the project
SOURCES = [
    "../cpp_utils/cloud/cloud.cpp",
    "grid_subsampling/grid_subsampling.cpp",
    "wrapper.cpp"
]

# Define the extension module
module = Extension(
    name="grid_subsampling",
    sources=SOURCES,
    extra_compile_args=['/std:c++11', '-D_GLIBCXX_USE_CXX11_ABI=0'],  
    include_dirs=[np.get_include()]  
)

# Run setup
setup(ext_modules=[module])

3.在终端分别运行上述两个文件夹中build.bat文件,观察到文件夹内多了两个.pyd文件即为编译成功。

二、问题解决 

按照上图方式使用该模块时发现报错“module not found error”,该问题是由第三级目录(cpp_subsampling和cpp_neighbors)路径不匹配导致的。

 只需将上图第一个红框中的目录改成radius_neighbors然后按照如下方式引用即可成功。

import cpp_wrappers.cpp_subsampling.grid_subsampling as cpp_subsampling
import cpp_wrappers.cpp_neighbors.radius_neighbors as cpp_neighbors

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

<Yesterday>

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值