linux Pyinstaller 打包运行报错 OSError: Cannot load native module ‘Crypto.Cipher._raw_ecb‘: Not found ‘_ra

linux Pyinstaller 打包运行报错
OSError: Cannot load native module ‘Crypto.Cipher._raw_ecb’: Not found '_raw_ecb.cpython-37m-x86_64-

原因是缺少文件hook-Crypto.py文件路径在/usr/local/lib/python3.7/site-packages/PyInstaller/hooks
里面添加一个文件内容为:

#-----------------------------------------------------------------------------
# Copyright (c) 2005-2018, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
 
"""
Hook for PyCryptodome library: https://pypi.python.org/pypi/pycryptodome
PyCryptodome is an almost drop-in replacement for the now unmaintained
PyCrypto library. The two are mutually exclusive as they live under
the same package ("Crypto").
PyCryptodome distributes dynamic libraries and builds them as if they were
Python C extensions (even though they are not extensions - as they can't be
imported by Python). It might sound a bit weird, but this decision is rooted
in PyPy and its partial and slow support for C extensions. However, this also
invalidates several of the existing methods used by PyInstaller to decide the
right files to pull in.
Even though this hook is meant to help with PyCryptodome only, it will be
triggered also when PyCrypto is installed, so it must be tested with both.
Tested with PyCryptodome 3.5.1, PyCrypto 2.6.1, Python 2.7 & 3.6, Fedora & Windows
"""
 
import os
import glob
 
from PyInstaller.compat import EXTENSION_SUFFIXES
from PyInstaller.utils.hooks import get_module_file_attribute
 
# Include the modules as binaries in a subfolder named like the package.
# Cryptodome's loader expects to find them inside the package directory for
# the main module. We cannot use hiddenimports because that would add the
# modules outside the package.
 
binaries = []
binary_module_names = [
    'Crypto.Math',      # First in the list
    'Crypto.Cipher',
    'Crypto.Util',
    'Crypto.Hash',
    'Crypto.Protocol',
]
 
try:
    for module_name in binary_module_names:
        m_dir = os.path.dirname(get_module_file_attribute(module_name))
        for ext in EXTENSION_SUFFIXES:
            module_bin = glob.glob(os.path.join(m_dir, '_*%s' % ext))
            for f in module_bin:
                binaries.append((f, module_name.replace('.', os.sep)))
except ImportError:
    # Do nothing for PyCrypto (Crypto.Math does not exist there)
    pass

然后和crypto有关的模块都卸载一遍。最后安装pip3 install pycryptodome 。别装别的模块(比如pycrypto、pycryptodomex、 ),没用的只需要pycryptodome 。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]:根据您提供的信息,您在使用pyinstaller打包mmdection目标检测的时候遇到了报错"ModuleNotFoundError: No module named 'mmcv._ext'"。这个错误通常是由于打包过程中缺少了mmcv._ext模块导致的。引用\[2\]:另外,您还提到在执行二进制文件时遇到了"ModuleNotFoundError: No module named 'distutils'"的错误。这个错误通常是由于缺少distutils模块导致的。引用\[3\]:最后,您还提到在使用pyinstaller打包salt最新版本时遇到了"No module named 'setuptools._distutils'"的错误。这个错误通常是由于缺少setuptools._distutils模块导致的。 针对这些错误,您可以尝试以下解决方法: 1. 确保在打包之前已经正确安装了相关的依赖库。可以使用pip命令安装缺少的模块,比如在命令行中执行"pip install mmcv"来安装mmcv模块。 2. 检查您的打包配置文件是否正确配置了相关的依赖项。确保在打包过程中包含了所有需要的模块和文件。 3. 尝试使用不同的打包工具或者配置选项。有时候不同的打包工具或者不同的配置选项可以解决一些特定的问题。 4. 如果以上方法都没有解决问题,您可以尝试在打包之前先运行一下您的代码,确保代码本身没有问题。如果代码可以正常运行,那么可能是打包过程中的一些配置问题导致的错误。 希望以上方法可以帮助您解决问题。如果问题仍然存在,请提供更多的详细信息,以便我们能够更好地帮助您解决问题。 #### 引用[.reference_title] - *1* [python 源码运行时正常,pyinstaller打包运行报错ModuleNotFoundError: No module named ‘mmcv._ext‘,...](https://blog.csdn.net/gc5218112/article/details/125172123)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [python pyinstaller打包执行文件 运行报错ModuleNotFoundError: No module named ‘setuptools._distutils...](https://blog.csdn.net/whatday/article/details/127095387)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值