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

安装运行einsteinpy遇SystemError:numpy.random.mtrand模块执行失败

解决EinsteinPy与NumPy版本不匹配导致的numpy.random.mtrand加载错误

问题根源

你遇到的SystemError: execution of module numpy.random.mtrand failed without setting an exception错误,核心原因是Python 3.11与EinsteinPy稳定版的依赖兼容性不匹配——EinsteinPy 0.4.0及之前的稳定版本对Python 3.11的适配不完善,且高版本NumPy(1.24+)的C扩展模块在Python 3.11下的加载逻辑与EinsteinPy的依赖链冲突。

具体解决方案

方案1:降级Python到兼容版本(推荐)

EinsteinPy稳定版(0.4.0)官方支持Python 3.8~3.10,搭配以下版本组合可完全解决问题:

  1. 卸载现有冲突包:
    pip uninstall -y einsteinpy numpy scipy matplotlib
    
  2. 安装验证过的兼容版本:
    pip install numpy==1.23.5 einsteinpy==0.4.0 scipy==1.9.3 matplotlib==3.6.3
    

方案2:保留Python 3.11,尝试EinsteinPy开发版

若不想降级Python,可尝试安装EinsteinPy的开发分支(适配Python 3.11),但稳定性不如稳定版:

pip uninstall -y einsteinpy numpy
pip install numpy==1.24.3 git+https://github.com/einsteinpy/einsteinpy.git

额外排查步骤

  • 确保在干净的虚拟环境中操作,避免全局包依赖污染
  • 执行pip cache purge清理pip缓存后再重装,防止安装损坏的缓存包
  • 验证NumPy安装有效性:运行以下命令,无报错则说明NumPy加载正常
    python -c "import numpy; print(numpy.__version__); import numpy.random.mtrand"
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 03:23:28