Cython——[AttributeError: ‘MSVCCompiler‘ object has no attribute ‘compiler_so‘]解决方案
生活随笔
收集整理的這篇文章主要介紹了
Cython——[AttributeError: ‘MSVCCompiler‘ object has no attribute ‘compiler_so‘]解决方案
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題描述
運行環境
Windows 10
Python3.7
TensorFlow 1.3.0
GitHub文件URL:https://github.com/xiaofengShi/CHINESE-OCR/blob/master/ctpn/lib/utils/setup.py
python setup.py build_ext --inplace running build_ext Traceback (most recent call last):File "setup.py", line 150, in <module>cmdclass={'build_ext': custom_build_ext},File "C:\Users\USER\AppData\Local\Programs\Python\Python35\lib\distutils\core.py", line 148, in setupdist.run_commands()File "C:\Users\USER\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 955, in run_commandsself.run_command(cmd)File "C:\Users\USER\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_commandcmd_obj.run()File "C:\Users\USER\AppData\Local\Programs\Python\Python35\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run_build_ext.build_ext.run(self)File "C:\Users\USER\AppData\Local\Programs\Python\Python35\lib\distutils\command\build_ext.py", line 338, in runself.build_extensions()File "setup.py", line 104, in build_extensionscustomize_compiler_for_nvcc(self.compiler)File "setup.py", line 77, in customize_compiler_for_nvccdefault_compiler_so = self.compiler_so AttributeError: 'MSVCCompiler' object has no attribute 'compiler_so'問題分析
該.compiler_so字段僅存在于distutils.unixcompiler.UnixCCompiler和派生中。
因此,此程序包不支持標準的Windows構建環境。
根據Windows上的“從源構建” |?TensorFlow,應該使用MSYS2構建。
解決方案
方法一
刪除所有自定義配置,采取默認方式。
from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonizesetup(name = 'hellocython',ext_modules=cythonize([Extension("hellocython", ["hellocython.pyx"]),]), ) python setup.py build python setup.py install?方法二
使用MinGW64編譯器:https://www.jianshu.com/p/50105307dea5
參考文章
AttributeError: 'MSVCCompiler' object has no attribute 'compiler_so'
【Cython】Cython在Windows環境下的部署安裝
cython: 使用mingw編譯器
win配置faster-rcnn、yolo、ctpn等目標檢測的幾個大坑
總結
以上是生活随笔為你收集整理的Cython——[AttributeError: ‘MSVCCompiler‘ object has no attribute ‘compiler_so‘]解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Cython——[FutureWarni
- 下一篇: Cython——Windows环境下配置