我对cython东西不熟悉,并且尝试了很多事情,但是我仍然无法编译我的代码。
我将在此处提供与我的问题相关的任何信息:
Spyder版本:3.3.4
Python版本:3.6.8
操作系统:Windows 10 64位
最近安装了mingw
最近遵循了here的说明来下载Microsoft Visual C++ Redistributable for Visual Studio 2017
还阅读了其他帖子,例如this
几个小时后,我仍然非常迷茫,沮丧和困惑。不知道该怎么做才能使“ hello world”等效于cython代码在我的Python环境中工作。我真的需要帮助谢谢大家
以下是我到目前为止创建的文件
测试ground.py:
import pyximport
pyximport.install()
from cython_testin import test
X = test(10)
setup.py
import setuptools
from distutils.core import setup
from Cython.Build import cythonize
setup(#name = 'cython ema',
ext_modules = cythonize('cython_testin.pyx'))
cython_testin.pyx:
cpdef int test(int x):
cdef int y = 0
cdef int i
for i in range(x):
y+=1
return y
错误消息:
runfile('C:/Users/User/Desktop/all python file/5.0.4/testing ground.py', wdir='C:/Users/User/Desktop/all python file/5.0.4')
Traceback (most recent call last):
File "<ipython-input-3-1755e5d47c7c>", line 1, in <module>
runfile('C:/Users/User/Desktop/all python file/5.0.4/testing ground.py', wdir='C:/Users/User/Desktop/all python file/5.0.4')
File "C:\Users\User\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\User\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/User/Desktop/all python file/5.0.4/testing ground.py", line 10, in <module>
from cython_testin import test
File "C:\Users\User\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 462, in load_module
language_level=self.language_level)
File "C:\Users\User\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 231, in load_module
raise exc.with_traceback(tb)
File "C:\Users\User\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 215, in load_module
inplace=build_inplace, language_level=language_level)
File "C:\Users\User\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 191, in build_module
reload_support=pyxargs.reload_support)
File "C:\Users\User\Anaconda3\lib\site-packages\pyximport\pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "C:\Users\User\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\User\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\User\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "C:\Users\User\Anaconda3\lib\distutils\command\build_ext.py", line 339, in run
self.build_extensions()
File "C:\Users\User\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 194, in build_extensions
self.build_extension(ext)
File "C:\Users\User\Anaconda3\lib\distutils\command\build_ext.py", line 533, in build_extension
depends=ext.depends)
File "C:\Users\User\Anaconda3\lib\distutils\_msvccompiler.py", line 345, in compile
self.initialize()
File "C:\Users\User\Anaconda3\lib\distutils\_msvccompiler.py", line 238, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\Users\User\Anaconda3\lib\distutils\_msvccompiler.py", line 134, in _get_vc_env
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
ImportError: Building module cython_testin failed: ['distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat\n']