1

を使用する非常に単純なcythonコードがありますprange。これは、Linuxで正常に機能します。しかし、私がWindowsでそれをやろうとすると。コンパイルはできるがインポートできないという問題が発生しました。

ImportError: DLL load failed: This application has failed to start because the a
pplication configuration is incorrect. Reinstalling the application may fix this
problem.

また、ウィンドウズではできませんfrom cython.parallel import threadlocalか?!変...

誰かが方向を示すことができますか?

システムは正常に動作します:linux64、コンパイラgcc、パッケージ:Python 2.7、cython 0.16

システムに問題があります:Win64、コンパイラ:MSVC VS2008、パッケージ:Python 2.7、cython 0.16

これが私の単純なcythonpyxです:

cimport cython
from cython.parallel import prange

def f(int n):
    cdef int i
    cdef int sum = 0
    for i in prange(n, nogil=True):
        sum += i
    print sum

これが私のsetup.pyです:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np


setup(
    cmdclass = {'build_ext': build_ext},
    include_dirs = [np.get_include()], 
    ext_modules = [Extension("pcython1",  ["pcython1.pyx"],extra_compile_args=['/openmp',],),]
)
4

2 に答える 2

1

VS2008 インストーラーのバグにより、amd64_microsoft.vc90.openMP が wi​​nSxS にインストールされません。openMP ランタイムをインストールすると、この問題は解決します。

詳細については、この質問を参照してください: x64 プログラミング用に VS2008 を適切にセットアップする方法は?

于 2012-11-04T23:41:19.637 に答える
0

MinGWを使用して ( cython で mingw を適切にセットアップするには、この質問を参照してください)、 setup.pyを次のように更新します。

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np

ext_modules = [Extension("convolve_cy", ["convolve_cy.pyx"],
                         extra_compile_args = ["-O3", "-fopenmp"],
                         extra_link_args=["-fopenmp"])]

setup (
    name = 'performance test app',
    cmdclass = {'build_ext': build_ext},
    include_dirs = [np.get_include()],
    ext_modules = ext_modules,
)

これは、Python 2.7 と cython 2.0 を搭載した windows7 マルチコア 64 ビット マシンで動作しています。

于 2014-01-22T16:19:20.027 に答える