处理打包中的ModuleNotFoundError: No module named ‘_cffi_backend‘

背景:

在python项目中引入paramiko库后打包。

问题:

  • 运行exe提示:ModuleNotFoundError: No module named ‘_cffi_backend‘

    解决方式:在本地的python目录下,找到_cffi_backend.cp38-win_amd64.pyd,复制到打包的根目录下。重新运行exe文件。(类似的引入其他库后初始化异常处理方式一样)

  • 运行exe,发现由于引入的nacl库初始化异常。

 File "D:\work\boradxt\pythonProject\deviceSet0.04\main\paramiko\__init__.py", line 22, in <module>
    from paramiko.transport import SecurityOptions, Transport
  File "D:\work\boradxt\pythonProject\deviceSet0.04\main\paramiko\transport.py", line 90, in <module>
    from paramiko.ed25519key import Ed25519Key
  File "D:\work\boradxt\pythonProject\deviceSet0.04\main\paramiko\ed25519key.py", line 22, in <module>
    import nacl.signing
  File "D:\work\boradxt\pythonProject\deviceSet0.04\main\nacl\signing.py", line 17, in <module>
    import nacl.bindings
  File "D:\work\boradxt\pythonProject\deviceSet0.04\main\nacl\bindings\__init__.py", line 17, in <module>
    from nacl.bindings.crypto_aead import (
  File "D:\work\boradxt\pythonProject\deviceSet0.04\main\nacl\bindings\crypto_aead.py", line 18, in <module>
    from nacl._sodium import ffi, lib
SystemError: initialization of _sodium did not return an extension module

解决方案:
在本地的python目录下,找到_cffi_backend.cp38-win_amd64.pyd,复制到打包的根目录下。重新运行exe文件。(类似的引入其他库后初始化异常处理方式一样)
处理打包中的ModuleNotFoundError: No module named ‘_cffi_backend‘_第1张图片

你可能感兴趣的:(common,problems,python)