cython编译python pyd,Cython pyd文件未通过python导入

I'm writing a program in python that simulates the reaction of particles, with the aim of teaching the user about particle reactions. As python was too slow at doing the necessary processing, I turned to Cython for speed gains and it worked a treat. I can compile my .pyx file into a .pyd file that can be imported and run from python with a simple import statement (i.e. "import module").

However, the program eventually has to run on another person's computer, and on this computer, the .pyd file will not import. When I try I get this error message:

"ImportError: DLL load failed: The specified module could not be found."

The .pyd file is in exactly the same location on both computers, however, I am running python 3.6 while the other computer has python 3.3 installed. Also, my computer has Cython installed while the other computer does not. Both machines are 32-bit.

I cannot simply compile the entire program to a .exe file as the other computer has a block on .exe files.

I have trawled through stack's questions on Cython, and have also studied the Cython documentation, all to no avail.

Can someone explain to me why the import isn't working, and how I can get it to work? Some extra background on exactly what .pyd files are and how python calls them would also be nice.

EDIT: I run the program from a file called main.py . In the same directory, I have a folder called main, which stores the code I use in modules. main.py calls PageManager.py, which calls ParticleModel.py, which calls MoveParticles.pyd.

(These three files are stored in the folder main). I use the statement

"import main.MoveParticles"

to import the .pyd file, which works on my computer.

解决方案

Ok, the difficulty here arose from confusion over which DLL is missing.

I had (naively) assumed that because I was trying to import a .pyd file, which is essentially a DLL, (Python C extension: Use extension PYD or DLL?), that this was causing the error.

However, what actually was causing the error was the lack of a DLL required to run my .pyd file. I resolved the issue by using a different version of python (3.5 to be precise), and after recompiling my .pyd file to work on python 3.5 the application worked a treat.

Summary: the computer attempting to run my file lacked some neccessary DLLs, and hence caused the program to crash.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值