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

scikit-rf导入报错:numpy与collections属性缺失问题求助

环境配置
  • Pop!OS 22.04 系统
  • 安装有 Anaconda
  • 基于 Python 3.8.18 的基础环境运行 Spyder
  • 调用其他环境的解释器,所有环境均已安装 spyder-kernels 2.4.4
导入 scikit-rf 报错情况
  • Python 3.9.16 + numpy 1.26.4 + scikit-rf 0.18.1 环境:
    执行 import skrf as rf 时触发报错:
AttributeError: module 'numpy' has no attribute 'complex'.
  • Python 3.12.2 + numpy 1.26.4 + scikit-rf 0.18.1 环境:
    执行相同导入命令时触发报错:
AttributeError: module 'collections' has no attribute 'Sequence'
问题原因及解决办法

原因

这两个报错都是 scikit-rf 0.18.1 的版本兼容性问题:

  1. numpy 1.20 及以上版本已弃用 numpy.complex 属性,改用 numpy.complex_,但 scikit-rf 0.18.1 仍在使用旧写法,导致在高版本 numpy 中报错。
  2. Python 3.10 及以上版本将 collections.Sequence 迁移到了 collections.abc.Sequence,scikit-rf 0.18.1 未适配该变更,因此在 Python 3.12 中触发报错。

解决办法

  1. 优先升级 scikit-rf 到最新稳定版本(推荐 0.25+),新版本已修复上述兼容性问题。
  2. 若无法升级 scikit-rf:
    • 针对 Python 3.9 环境,将 numpy 降级到 1.19.x 版本;
    • Python 3.12 与 scikit-rf 0.18.1 完全不兼容,需将 Python 降级到 3.9 及以下版本,或者必须升级 scikit-rf。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 00:40:00