本文主要是介绍使用pycocotools时出现undefined symbol: _Py_ZeroStruct,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题描述:
运行
from pycocotools.coco import COCO
报错:
ImportError: /home/elijha/PycharmProjects/LinkinNet/cocoapi-master/PythonAPI/pycocotools/_mask.so: undefined symbol: _Py_ZeroStruct
出错原因
stackoverflow的回答:
This error message is typical when there’s a version mismatch in Python modules. It could something like cython_bbox.so was compiled and linked against Python 2.7 and CNTK was compiled against Python 3.5. It’s hard to say exactly what the reason is but you can try to do make inside a python environment that matches your CNTK version and see if that works.
检查后发现,我把Cython安装在了python2.7的环境内,而且make也是在此环境下进行的。而import的环境是python3.5,因此出错。
解决方法
- 在python2.7下卸载Cython。(这一步其实可以不做,但是因为我从来不用这个环境,就也卸载了。)
- 进入python3.5,执行
pip install Cython
- 重进进入pycocotools文件夹,执行make。(即用python3重新运行pycocotools下的setup.py进行安装。)
- 重新运行
from pycocotools.coco import COCO
,正确。
这篇关于使用pycocotools时出现undefined symbol: _Py_ZeroStruct的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!