简体   繁体   English

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

[英]How to fix python `dlib` error: "symbol not found in flat namespace '_png_do_expand_palette_rgb8_neon'"?

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.我收到错误消息: symbol not found in flat namespace '_png_do_expand_palette_rgb8_neon'尽管为相关 Python 版本安装了dlib package,但仍会发生错误。

I am using VSCode, in case that is relevant.我正在使用 VSCode,以防万一。

Can anyone please help me to fix this bug?谁能帮我修复这个错误? 在此处输入图像描述

For me, this is a mac M1 specific issue, solved by linking libpng:对我来说,这是一个 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 

(replace 1.6.37 by your installed version of libpng) (将 1.6.37 替换为您安装的 libpng 版本)

I ended up having to install dlib from source:我最终不得不从源代码安装 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"

This was based on this issue on dlib which recommends installing libpng and this issue on homebrew which recommends adding the --compiler-flags .这是基于建议安装 libpng的 dlib 上的这个问题和建议添加--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.安装 libpng 并设置编译器标志并没有使错误 go 消失,绝望中我进入dlib/image_save/save_png.h注释掉断言。 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.鉴于我有 libpng,我设置了 DLIB_PNG_SUPPORT 并成功构建。

Then ensure your virtual environment is active (if applicable) and install it:然后确保您的虚拟环境处于活动状态(如果适用)并安装它:

python -m pip install .

Should work if you force a reinstall using:如果您使用以下命令强制重新安装应该可以工作:

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

That fixed it for me.那为我修好了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 符号未找到,预期在:平面命名空间 - Symbol not found, Expected in: flat namespace MacOSX + Boost_Python + PyFTGL: - 未找到符号,预期在:flat namespace - MacOSX + Boost_Python + PyFTGL :- Symbol not found, expected in: flat namespace 使用 pdftotext 导入错误 - 在平面命名空间中找不到符号 - Import error using pdftotext - symbol not found in flat namespace 如何解决ImportError: dlopen(): Symbol not found:.... Expected in: flat namespace - How to solve ImportError: dlopen(): Symbol not found:.... Expected in: flat namespace 在平面名称空间中找不到预期的ImportError dlopen()符号 - Importerror dlopen () symbol not found expected in flat namespace 在 macOS 12 上使用 Python@3.9 的 reportlab 在平面命名空间“_FT_Done_Face”中找不到符号 - Symbol not found in flat namespace '_FT_Done_Face' from reportlab with Python@3.9 on macOS 12 Scrapy startproject 命令在导入 etree、Mac M1 时失败。 错误消息是:“在平面命名空间中找不到符号” - Scrapy startproject command failed on import etree, Mac M1. The error message is: "symbol not found in flat namespace" 找不到符号:_mpfr_acos,应在以下位置输入:平面名称空间 - Symbol not found: _mpfr_acos, Expected in: flat namespace SWIG for C ++,未找到符号:预期用于:平面名称空间 - SWIG for C++, Symbol not found: Expected in: flat namespace “符号未找到/预期位于:平面名称空间”实际上是什么意思? - What does "Symbol not found / Expected in: flat namespace" actually mean?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM