cython编译python pyd,cython编译但未生成pyd文件

I tried to run a python code, say myfile.py (also tried to rename it as myfile.pyx) as follows:

import pyximport

pyximport.install(setup_args={"script_args":["--compiler=mingw32"]},

reload_support=True)

import myfile

myfile.mycode()

I am using PyCharm. The code seems to have run fine without any error and even gave me correct results on the Python Console within PyCharm.

However no pyd (or pxd) files were generated. How can I know if my code (myfile.mycode()) ran via Cython or via regular Python?

I am using Python 3.4, Cython 0.21.2.

Thanks

解决方案

When using pyximport it will generate a temporary pyd file which is not in the working directory. You probably want to build a setup.py which will look something like:

from distutils.core import setup

from distutils.extension import Extension

from Cython.Distutils import build_ext

ext_modules = [Extension('myfile',

['myfile.pyx'],

)]

setup(

name = 'myfile',

cmdclass = {'build_ext': build_ext},

ext_modules = ext_modules

)

which you can compile using:

python setup.py build_ext -i clean

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值