Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 python distutils try安装程序_Python 2.7_Cython_Distutils - Fatal编程技术网

Python 2.7 python distutils try安装程序

Python 2.7 python distutils try安装程序,python-2.7,cython,distutils,Python 2.7,Cython,Distutils,我正在尝试使用distutils.core.setup编译一些cython代码文件 为了防止编译崩溃,但为了尽可能多地继续,我将每个文件扩展名放在try语句中 from distutils.core import setup, Extension from Cython.Build import cythonize from Cython.Distutils import build_ext import numpy as np pyx = [#file 1 Extension(

我正在尝试使用distutils.core.setup编译一些cython代码文件 为了防止编译崩溃,但为了尽可能多地继续,我将每个文件扩展名放在try语句中

from distutils.core import setup, Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import numpy as np

pyx = [#file 1
       Extension('file1',
       include_dirs=[np.get_include()],
       sources ["file1.pyx"]),

       #file 2
       Extension('file2',
       include_dirs=[np.get_include()],
       language="c",
       sources = ["file2.pyx"]),

       #rest of files
       ]

       # compile extensions
       for E in pyx :
           try:
               setup( ext_modules = [E], cmdclass={'build_ext': build_ext})
           except Exception as e:
               print "THIS IS AN ERROR", e
除了出现错误外,一切都很顺利,试着抓住似乎毫无用处。编译将停止,而不执行EXPECT语句


知道为什么要这样做吗?

系统退出必须包含在

# compile extensions
for E in pyx :
    try:
        setup( ext_modules = [E], cmdclass={'build_ext': build_ext})
    except (Exception, SystemExit) as e:
        print "THIS IS AN ERROR", e

SystemExit必须包含在除

# compile extensions
for E in pyx :
    try:
        setup( ext_modules = [E], cmdclass={'build_ext': build_ext})
    except (Exception, SystemExit) as e:
        print "THIS IS AN ERROR", e

您是否检查了
distutils.core.setup
是否确实在某个扩展模块未生成时传播异常?是的。我引入了一个错误来验证try和except,但是安装程序在没有通过except的情况下正常崩溃。然后我建议启动pdb,并在任何
raise
上设置一个断点,然后从那里跟踪异常。你是对的。当遇到错误时,通过SystemExit进行安装。证明:如果某个扩展模块未生成,您是否检查了
distutils.core.setup
是否确实会传播异常?是的。我引入了一个错误来验证try和except,但是安装程序在没有通过except的情况下正常崩溃。然后我建议启动pdb,并在任何
raise
上设置一个断点,然后从那里跟踪异常。你是对的。当遇到错误时,通过SystemExit进行安装。证明: