无法安装pyrebase:多次重装仍无法导入,pycryptodome安装失败求助
报错信息
note: This error originates from a subprocess, and is likely not a problem with pip.
Rolling back uninstall of pycryptodome
Moving to c:\users\f4bri\appdata\local\programs\python\python311\lib\site-packages\crypto
from C:\Users\f4bri\AppData\Local\Programs\Python\Python311\Lib\site-packages~rypto
Moving to c:\users\f4bri\appdata\local\programs\python\python311\lib\site-packages\pycryptodome-3.21.0.dist-info
from C:\Users\f4bri\AppData\Local\Programs\Python\Python311\Lib\site-packages~ycryptodome-3.21.0.dist-info
error: legacy-install-failure× Encountered error while trying to install package.
╰─> pycryptodome
解决方案
清理残留文件
手动删除Python site-packages目录下的pycryptodome残留文件:
路径:C:\Users\f4bri\AppData\Local\Programs\Python\Python311\Lib\site-packages\
删除以下文件夹:crypto~ryptopycryptodome-3.21.0.dist-info~ycryptodome-3.21.0.dist-info
升级pip及依赖工具
打开命令提示符执行:python -m pip install --upgrade pip setuptools wheel单独安装兼容的pycryptodome
优先安装二进制包避免编译失败:pip install pycryptodome --only-binary :all:若仍失败,尝试指定兼容Python3.11的版本:
pip install pycryptodome==3.20.0重新安装pyrebase
确认pycryptodome安装成功后,执行:pip install pyrebase验证安装
启动Python交互环境,执行导入命令测试:import pyrebase无报错则说明安装完成。
内容的提问来源于stack exchange,提问作者Fabrício Pereira Diniz

