You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

安装wrf-python库时出现ModuleNotFoundError错误求助

安装wrf-python库时出现ModuleNotFoundError错误求助

嗨,我之前也碰到过一模一样的问题,给你梳理下解决办法哈!

从你贴的错误日志能看出来,核心问题是缺少numpy.distutils模块——这是因为numpy在1.24版本之后移除了这个组件,但wrf-python的安装脚本还依赖它。下面是具体的解决步骤:

第一步:安装兼容版本的numpy

先回退到还包含numpy.distutils的旧版本,比如1.23.5(这个版本亲测能用),执行命令:

pip install numpy==1.23.5

第二步:重新安装wrf-python

等numpy安装完成后,再尝试安装wrf-python:

pip install wrf-python

额外建议

如果你的Python环境里有多个numpy版本冲突,建议用虚拟环境来隔离依赖,避免全局环境混乱。比如用venv创建虚拟环境:

# 创建虚拟环境
python -m venv wrf-env
# 激活虚拟环境(Windows系统)
wrf-env\Scripts\activate
# 激活虚拟环境(Linux/macOS系统)
source wrf-env/bin/activate

激活后再执行上面的安装步骤,成功率会更高~

附上你提供的错误日志供参考:

error: subprocess-exited-with-error

python setup.py egg_info did not run successfully.
exit code: 1

[6 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "C:\Users\HP\AppData\Local\Temp\pip-install-oyk6_k1z\wrf-python_4d4fb187dd8b475c900ed0c20f1b8158\setup.py", line 17, in
import numpy.distutils.core
ModuleNotFoundError: No module named 'numpy.distutils'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Encountered error while generating package metadata.

See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

备注:内容来源于stack exchange,提问作者Priyanka Garsole

火山引擎 最新活动