如何修复 python `dlib` 错误:“在平面命名空间‘_png_do_expand_palette_rgb8_neon’中找不到符号”?

发布于 2025-01-10 05:26:31 字数 286 浏览 1 评论 0原文

我收到错误:在平面命名空间“_png_do_expand_palette_rgb8_neon”中找不到符号 尽管已为相关 Python 版本安装了 dlib 包,但仍会发生错误。

我正在使用 VSCode,以防相关。

谁能帮我修复这个错误吗? 输入图片此处描述

I am getting the error: symbol not found in flat namespace '_png_do_expand_palette_rgb8_neon'
The error occurs in spite of the dlib package being installed for the relevant Python version.

I am using VSCode, in case that is relevant.

Can anyone please help me to fix this bug?
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

檐上三寸雪 2025-01-17 05:26:36

我最终不得不从源代码安装 dlib:

git clone https://github.com/davisking/dlib.git
cd dlib
python setup.py install --set DLIB_PNG_SUPPORT=1 --compiler-flags "-I/usr/local/include -L/opt/homebrew/lib -lpng"

这是基于 dlib 上的此问题建议安装 libpng 和 此问题homebrew 建议添加 --compiler-flags

安装 libpng 并设置编译器标志并没有使错误消失,绝望中我进入 dlib/image_save/save_png.h 注释掉断言。然而,代码中有一个有用的推荐:

#ifndef DLIB_PNG_SUPPORT
            /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                You are getting this error because you are trying to use save_png()
                but you haven't defined DLIB_PNG_SUPPORT.  You must do so to use
                this function.   You must also make sure you set your build environment
                to link against the libpng library.
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
            COMPILE_TIME_ASSERT(sizeof(image_type) == 0);
#else
...

鉴于我有 libpng,我设置了 DLIB_PNG_SUPPORT 并且构建成功。

然后确保您的虚拟环境处于活动状态(如果适用)并安装它:

python -m pip install .

I ended up having to install dlib from source:

git clone https://github.com/davisking/dlib.git
cd dlib
python setup.py install --set DLIB_PNG_SUPPORT=1 --compiler-flags "-I/usr/local/include -L/opt/homebrew/lib -lpng"

This was based on this issue on dlib which recommends installing libpng and this issue on homebrew which recommends adding the --compiler-flags.

Installing libpng and setting the compiler flags didn't make the error go away, and in desperation I went into dlib/image_save/save_png.h to comment out the assert. However, there was a helpful commend in the code:

#ifndef DLIB_PNG_SUPPORT
            /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                You are getting this error because you are trying to use save_png()
                but you haven't defined DLIB_PNG_SUPPORT.  You must do so to use
                this function.   You must also make sure you set your build environment
                to link against the libpng library.
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
            COMPILE_TIME_ASSERT(sizeof(image_type) == 0);
#else
...

Given that I have libpng, I set DLIB_PNG_SUPPORT and building succeeded.

Then ensure your virtual environment is active (if applicable) and install it:

python -m pip install .
浪推晚风 2025-01-17 05:26:33

如果您使用以下命令强制重新安装,应该可以工作:

pip3 install dlib --force-reinstall --no-cache-dir --global-option=build_ext

这为我修复了它。

Should work if you force a reinstall using:

pip3 install dlib --force-reinstall --no-cache-dir --global-option=build_ext

That fixed it for me.

红墙和绿瓦 2025-01-17 05:26:31

对我来说,这是 mac M1 特定问题,通过链接 libpng 解决:(

brew install libpng
export C_INCLUDE_PATH=/opt/homebrew/Cellar/libpng/1.6.37/include
export LIBRARY_PATH=/opt/homebrew/Cellar/libpng/1.6.37/lib
pip3 install dlib --force-reinstall 

用您安装的 libpng 版本替换 1.6.37)

For me, this is a mac M1 specific issue, solved by linking libpng:

brew install libpng
export C_INCLUDE_PATH=/opt/homebrew/Cellar/libpng/1.6.37/include
export LIBRARY_PATH=/opt/homebrew/Cellar/libpng/1.6.37/lib
pip3 install dlib --force-reinstall 

(replace 1.6.37 by your installed version of libpng)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文