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库:- 卸载现有fitsio:
pip uninstall -y fitsio - 克隆源码并编译安装(若CFITSIO路径特殊,需指定
--cfitsio参数):
或直接通过pip从源码安装:git clone https://github.com/esheldon/fitsio.git cd fitsio python setup.py install --cfitsio=/path/to/your/cfitsiopip install git+https://github.com/esheldon/fitsio.git
- 卸载现有fitsio:
排查conda环境依赖冲突
若使用conda环境,可能是conda安装的CFITSIO与pip安装的fitsio不兼容:- 尝试用conda安装fitsio:
conda install -c conda-forge fitsio - 或卸载conda环境中的CFITSIO后,重新用pip安装fitsio:
conda uninstall -y cfitsio pip install fitsio --no-cache-dir
- 尝试用conda安装fitsio:
修正库加载路径
确保系统加载的CFITSIO库是fitsio编译时依赖的版本:- 查看当前
LD_LIBRARY_PATH:echo $LD_LIBRARY_PATH - 将正确的CFITSIO库路径添加到环境变量:
export LD_LIBRARY_PATH=/path/to/cfitsio/lib:$LD_LIBRARY_PATH
- 查看当前
内容的提问来源于stack exchange,提问作者user23669209
相关产品推荐
相关产品推荐

