You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac OS High Sierra下Miniconda安装CERN ROOT遇libpng冲突求助

问题:MacOS High Sierra下Miniconda环境启动ROOT时遭遇libpng冲突错误

环境背景

  • 系统版本:Mac OS High Sierra 10.13.4
  • 需求目标:在独立conda环境中部署Python3、CERN ROOT和Jupyter Lab,避免干扰系统原生的Python2.7+ROOT环境
  • 初始$PATH配置:
    /usr/local/Cellar/root/6.10.08/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
    

已执行操作步骤

  1. 安装Miniconda3
    从全新终端执行以下命令,将Miniconda3安装到/Users/urania277/miniconda3:

    wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
    bash Miniconda3-latest-MacOSX-x86_64.sh
    

    并在.bash_profile中添加路径配置:

    export PATH="/Users/urania277/miniconda3/bin:$PATH"
    
  2. 创建并激活专属conda环境
    添加指定频道后创建环境:

    conda config --add channels https://conda.anaconda.org/NLeSC
    conda create --name=Root6Python3 root=6 python=3
    conda activate Root6Python3
    
  3. 配置ROOT环境变量
    执行ROOT自带的环境配置脚本:

    source /Users/urania277/miniconda3/envs/Root6Python3/bin/thisroot.sh
    

错误详情

启动ROOT时触发动态库符号冲突,报错信息如下:

(Root6Python3) jocke:~ urania277$ root
dyld: Symbol not found: __cg_png_create_info_struct
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /Users/urania277/miniconda3/envs/Root6Python3/lib/libPng.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Abort trap: 6

解决思路

我之前在MacOS环境下遇到过类似的libpng版本冲突问题,给你几个实用的排查和修复方向:

  1. 临时调整动态库加载优先级
    MacOS的dyld默认优先加载conda环境内的库,但系统ImageIO框架依赖原生libpng,和conda环境中的版本不兼容。可以在启动ROOT前临时修改DYLD_LIBRARY_PATH,让系统库优先被加载:

    export DYLD_LIBRARY_PATH=/System/Library/Frameworks/ImageIO.framework/Versions/A/Resources:$DYLD_LIBRARY_PATH
    root
    

    如果测试有效,可以把这条命令写入环境的激活脚本(比如/Users/urania277/miniconda3/envs/Root6Python3/etc/conda/activate.d/env_vars.sh),每次激活环境时自动生效。

  2. 替换conda环境中的libpng为系统兼容版本
    尝试卸载conda环境内的libpng,强制使用系统原生版本:

    conda remove --force libpng
    

    若ROOT依赖特定版本的libpng,可以尝试安装和High Sierra系统原生版本匹配的包(比如1.6.34版本,和该系统自带libpng兼容性较好):

    conda install libpng=1.6.34
    
  3. 切换到兼容性更好的conda频道
    你所用的NLeSC频道的ROOT包可能依赖的libpng版本存在兼容性问题,建议切换到conda-forge频道重新安装ROOT:

    conda config --remove channels https://conda.anaconda.org/NLeSC
    conda config --add channels conda-forge
    conda create --name=Root6Python3_new root=6 python=3
    conda activate Root6Python3_new
    source thisroot.sh
    root
    
  4. 手动修改ROOT二进制文件的依赖路径
    用install_name_tool工具修改ROOT可执行文件的libpng依赖,指向系统原生库:

    # 先找到系统原生libpng的路径
    find /System/Library -name libpng*.dylib
    # 假设找到路径为/System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libpng16.dylib
    install_name_tool -change /Users/urania277/miniconda3/envs/Root6Python3/lib/libpng.dylib /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libpng16.dylib /Users/urania277/miniconda3/envs/Root6Python3/bin/root.exe
    

    这个方法比较硬核,需要确保路径准确,若ROOT还有其他依赖libpng的库文件,可能需要逐一修改。

内容的提问来源于stack exchange,提问作者CatDogLund

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:28:48