且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python:从编译的源代码中导入错误

更新时间:2022-11-02 17:43:36

我刚刚遇到这个问题。



对我有用的是在使用pyinstaller构建时添加 - hidden-import = _cffi_backend p>

I'm having problems while running a compiled source code. The code itself is correct and if I run python file.py everything goes fine; if I compile it with pyinstaller or software like this, and then I run the compiled file it says ImportError: No module named _cffi_backend. But when I open python and import cffi and/or _cffi_backend python doesn't show error. Investigating in my code I found that the problem is just with padding from cryptography, so if I don't import padding the output doesn't show errors (obviously errors comes because the code doesn't work well without padding module). Can someone help me?

I just ran into this issue as well.

What worked for me was adding in --hidden-import=_cffi_backend option when building with pyinstaller.