You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyCryptodome库报错:'SHA256_init'未找到的问题求助

解决PyCryptodome中SHA256_init符号找不到的错误

这个错误是PyCryptodome底层二进制库损坏、安装不完整或版本不兼容导致的,针对你的macOS环境,可按以下步骤解决:

  • 彻底卸载现有PyCryptodome
    先通过pip卸载:

    pip uninstall -y pycryptodome
    

    手动删除虚拟环境中残留的Crypto目录(路径参考你的错误信息):

    rm -rf /Users/thekc/PycharmProjects/MS_CS/venv/lib/python3.9/site-packages/Crypto
    
  • 重新安装PyCryptodome
    优先安装官方提供的二进制包:

    pip install pycryptodome
    

    若仍有问题,指定兼容Python3.9的稳定版本安装:

    pip install pycryptodome==3.19.0
    
  • 验证安装有效性
    运行以下测试代码确认功能正常:

    from Crypto.Hash import SHA256
    
    mess = b'hello'
    h = SHA256.new(mess)
    print(h.hexdigest())
    

    也可使用标准写法:h = SHA256.new(); h.update(mess),两种方式均有效

  • 额外排查项

    • 确保操作时已正确激活目标虚拟环境,避免混用全局Python环境
    • 检查macOS的Xcode命令行工具是否完整,执行xcode-select --install修复缺失组件
    • 若为M系列芯片Mac,确认使用的Python是原生arm64版本,或通过Rosetta模式运行终端后重新安装

内容的提问来源于stack exchange,提问作者Krishna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 07:22:40