numpy.get_include()

此篇博客介绍了如何使用`numpy.get_include()`函数在编译扩展模块时定位NumPy包含目录,适用于依赖NumPy的Python扩展开发。通过cykdtree库的路径获取作为示例。
def get_include():
    """
    Return the directory that contains the NumPy \\*.h header files.
    Extension modules that need to compile against NumPy should use this
    function to locate the appropriate include directory.
    Notes
    -----
    When using ``distutils``, for example in ``setup.py``.
    ::
        import numpy as np
        ...
        Extension('extension_name', ...
                include_dirs=[np.get_include()])
        ...
    """
    import cykdtree
    return os.path.dirname(cykdtree.__file__) 

Report issues at https://termux.dev/issues ~ $ # 安装核心依赖 pkg install python cmake make clang libjpeg-turbo libpng openblas -y pip install numpy # 获取 OpenCV 源码 git clone https://github.com/opencv/opencv git clone https://github.com/opencv/opencv_contrib # 配置编译参数 cd opencv && mkdir build && cd build cmake \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DBUILD_opencv_python3=ON \ -DPYTHON3_INCLUDE_DIR=$(python -c "import sysconfig;print(sysconfig.get_path('include'))") \ -DPYTHON3_LIBRARY=$(find $PREFIX/lib -name 'libpython3.*.so') \ -DPYTHON3_NUMPY_INCLUDE_DIRS=$(python -c "import numpy;print(numpy.get_include())") \ -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ -DWITH_OPENBLAS=ON \ FIX/lib/python3.*/site-packages/e-packages/cv2/*.so $PRE Checking availability of current mirror: [*] https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main: ok Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package openblas Requirement already satisfied: numpy in /data/data/com.termux/files/usr/lib/python3.12/site-packages (2.2.5) fatal: destination path 'opencv' already exists and is not an empty directory. fatal: destination path 'opencv_contrib' already exists and is not an empty directory. mkdir: cannot create directory ‘build’: File exists CMake Warning: Ignoring extra path from command line: ".." CMake Error: The source directory "/data/data/com.termux/files/home" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. make: *** No targets specified and no makefile found. Stop. make: *** No rule to make target 'install'. Stop. ~/opencv
07-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Wanderer001

ROIAlign原理

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

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

打赏作者

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

抵扣说明:

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

余额充值