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

Python 3.7导入fitsio 1.2.1报错:undefined symbol: fits_use_standard_strings

解决fitsio导入时的undefined symbol: fits_use_standard_strings错误

问题描述

在Python 3.7.0环境中导入fitsio 1.2.1时,触发以下ImportError:

/home/apc44/anaconda3/envs/pylab_py37/lib/python3.7/site-packages/fitsio/_fitsio_wrap.cpython-37m-x86_64-linux-gnu.so: undefined symbol: fits_use_standard_strings

已尝试更换fitsio及Python版本,问题仍未解决。


解决思路

  • 检查CFITSIO版本匹配性
    fits_use_standard_strings是CFITSIO库的函数,错误说明fitsio编译依赖的CFITSIO版本与当前环境加载的版本不兼容,或当前CFITSIO版本过低。执行以下命令查看版本:

    fitsinfo --version
    # 或使用
    cfitsio-config --version
    

    确保CFITSIO版本不低于3.47(该函数在较新版本中新增)。

  • 从源码编译安装fitsio
    放弃预编译wheel包,手动编译确保链接正确的CFITSIO库:

    1. 卸载现有fitsio:
      pip uninstall -y fitsio
      
    2. 克隆源码并编译安装(若CFITSIO路径特殊,需指定--cfitsio参数):
      git clone https://github.com/esheldon/fitsio.git
      cd fitsio
      python setup.py install --cfitsio=/path/to/your/cfitsio
      
      或直接通过pip从源码安装:
      pip install git+https://github.com/esheldon/fitsio.git
      
  • 排查conda环境依赖冲突
    若使用conda环境,可能是conda安装的CFITSIO与pip安装的fitsio不兼容:

    1. 尝试用conda安装fitsio:
      conda install -c conda-forge fitsio
      
    2. 或卸载conda环境中的CFITSIO后,重新用pip安装fitsio:
      conda uninstall -y cfitsio
      pip install fitsio --no-cache-dir
      
  • 修正库加载路径
    确保系统加载的CFITSIO库是fitsio编译时依赖的版本:

    1. 查看当前LD_LIBRARY_PATH:
      echo $LD_LIBRARY_PATH
      
    2. 将正确的CFITSIO库路径添加到环境变量:
      export LD_LIBRARY_PATH=/path/to/cfitsio/lib:$LD_LIBRARY_PATH
      

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 13:17:06